diff options
author | Saivan <savian@me.com> | 2018-04-23 20:25:41 +1000 |
---|---|---|
committer | Saivan <savian@me.com> | 2018-04-23 20:25:41 +1000 |
commit | 64b3144c89247d0be176bf01c28aa5fe6bef84d5 (patch) | |
tree | 1cb689a600c7804ee41eef66d63fb4f104c85e60 /bench | |
parent | 7a4979d0cfd4c4dbe91b53b69c62aa28c295af5c (diff) | |
download | svg.js-64b3144c89247d0be176bf01c28aa5fe6bef84d5.tar.gz svg.js-64b3144c89247d0be176bf01c28aa5fe6bef84d5.zip |
Added some timeline and Morphing functions
Diffstat (limited to 'bench')
-rw-r--r-- | bench/runner.html | 7 | ||||
-rw-r--r-- | bench/tests/10000-accesses.js | 35 |
2 files changed, 39 insertions, 3 deletions
diff --git a/bench/runner.html b/bench/runner.html index 965a884..6d1bed2 100644 --- a/bench/runner.html +++ b/bench/runner.html @@ -41,13 +41,14 @@ <script src="https://cdnjs.cloudflare.com/ajax/libs/snap.svg/0.5.1/snap.svg-min.js"></script> <script src="svg.bench.js"></script> <!--<script src="tests/10000-each.js"></script> --> - <script src="tests/10000-rects.js"></script> + <!-- <script src="tests/10000-rects.js"></script> <script src="tests/10000-circles.js"></script> <script src="tests/10000-paths.js"></script> <script src="tests/10000-boxes.js"></script> - <script src="tests/10000-pointArray-bbox.js"></script> + <script src="tests/10000-pointArray-bbox.js"></script> --> + <script src="tests/10000-accesses.js"></script> <script> SVG.bench.run() </script> </body> -</html>
\ No newline at end of file +</html> diff --git a/bench/tests/10000-accesses.js b/bench/tests/10000-accesses.js new file mode 100644 index 0000000..4c7dfea --- /dev/null +++ b/bench/tests/10000-accesses.js @@ -0,0 +1,35 @@ + +SVG.bench.describe('Access a dom attribues vs dom properties vs object properties', function(bench) { + bench.test('using an object', function() { + var sum = 0 + var obj = {x: "30"} + for (var i = 0; i < 1000000; i++) { + sum += obj.x * i + } + console.log(sum) + }) + + bench.test('figure out what the overhead is', function () { + var obj = bench.draw.rect(100, 100).move(0, 0) + }) + + bench.test('using dom attriutes', function () { + var sum = 0 + var obj = bench.draw.rect(100, 100).move(0, 0) + var node = obj.node + for (var i = 0; i < 1000000; i++) { + sum += node.getAttribute('x') * i + } + console.log(sum, node.getAttribute('x')) + }) + + bench.test('using dom properties', function () { + var sum = 0 + var obj = bench.draw.rect(100, 100).move(0, 0) + var node = obj.node + for (var i = 0; i < 1000000; i++) { + sum += node.x.baseVal * i + } + console.log(sum, node.x) + }) +}) |