aboutsummaryrefslogtreecommitdiffstats
path: root/bench/tests
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-10-08 15:18:53 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2018-10-08 15:18:53 +0200
commitd3dd6ad74b35e674ab24a8d9bf0c3b2f336b5bca (patch)
treebb6dfe01d1f2fc0ba270b42ae0a0bcb5a61f9349 /bench/tests
parent179187327810f9219437b371adada85b843f8b71 (diff)
downloadsvg.js-d3dd6ad74b35e674ab24a8d9bf0c3b2f336b5bca.tar.gz
svg.js-d3dd6ad74b35e674ab24a8d9bf0c3b2f336b5bca.zip
Optimized the matrix functions so that the transform function is a multitude faster for parameterized input
Diffstat (limited to 'bench/tests')
-rw-r--r--bench/tests/10000-transform.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/bench/tests/10000-transform.js b/bench/tests/10000-transform.js
new file mode 100644
index 0000000..0fcc162
--- /dev/null
+++ b/bench/tests/10000-transform.js
@@ -0,0 +1,32 @@
+SVG.bench.describe('Transform 1000000 rects', function(bench) {
+ let parameters = {
+ translate: [20, 30],
+ origin: [100, 100],
+ rotate: 25,
+ skew: [10, 30],
+ scale: 0.5
+ }
+
+ let matrixLike = {a:2, b:3, c:1, d:2, e:49, f:100}
+ let matrix = new SVG.Matrix(matrixLike)
+
+ let worker = new SVG.Matrix()
+ bench.test('with parameters', function() {
+ for (var i = 0; i < 1000000; i++)
+ worker.transform(parameters)
+ })
+
+ worker = new SVG.Matrix()
+ bench.test('with matrix like', function() {
+ for (var i = 0; i < 1000000; i++) {
+ worker.transform(matrixLike)
+ }
+ })
+
+ worker = new SVG.Matrix()
+ bench.test('with SVG.Matrix', function() {
+ for (var i = 0; i < 1000000; i++)
+ worker.transform(matrix)
+ })
+})
+