summaryrefslogtreecommitdiffstats
path: root/bench
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2016-08-04 21:19:53 +0200
committerwout <wout@impinc.co.uk>2016-08-04 21:19:53 +0200
commit0e23fcd9ef56f369763505dbb22c3f5ab23a0b17 (patch)
treef1a86a9a4d3cfdcee3b64b135118a5e9a2ed39fd /bench
parent16575bdca041c6f04042058d05b4867f882b65bd (diff)
downloadsvg.js-0e23fcd9ef56f369763505dbb22c3f5ab23a0b17.tar.gz
svg.js-0e23fcd9ef56f369763505dbb22c3f5ab23a0b17.zip
Added Snap.svg to benchmarking system
Diffstat (limited to 'bench')
-rw-r--r--bench/runner.html3
-rw-r--r--bench/svg.bench.js4
-rw-r--r--bench/tests/element-creation.js21
3 files changed, 20 insertions, 8 deletions
diff --git a/bench/runner.html b/bench/runner.html
index 0e005f1..c24cc8b 100644
--- a/bench/runner.html
+++ b/bench/runner.html
@@ -26,8 +26,9 @@
</head>
<body>
<div id="draw"></div>
- <svg id="native" width="100" height="1000" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs"></svg>
+ <svg id="native" width="100" height="100" xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs"></svg>
<script src="../dist/svg.js"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/snap.svg/0.4.1/snap.svg.js"></script>
<script src="svg.bench.js"></script>
<script src="tests/element-creation.js"></script>
<script>
diff --git a/bench/svg.bench.js b/bench/svg.bench.js
index 0cf46cc..7f1aa1e 100644
--- a/bench/svg.bench.js
+++ b/bench/svg.bench.js
@@ -6,6 +6,7 @@
, _before: function() {}
, _after: function() {}
, draw: SVG('draw')
+ , snap: Snap(100, 100)
, raw: document.getElementById('native')
// Add test
@@ -57,7 +58,7 @@
, write: function(name, ms) {
var test = document.createElement('div')
test.className = 'test'
- test.innerHTML = 'Compleded <span class="name">' + name + '</span> in <span class="ms">' + ms + 'ms</span>'
+ test.innerHTML = 'Completed <span class="name">' + name + '</span> in <span class="ms">' + ms + 'ms</span>'
this.pad().appendChild(test)
@@ -81,6 +82,7 @@
while(this.raw.hasChildNodes())
this.raw.removeChild(this.raw.lastChild)
this.draw.clear()
+ this.snap.clear()
}
}
diff --git a/bench/tests/element-creation.js b/bench/tests/element-creation.js
index 107c353..f0e4143 100644
--- a/bench/tests/element-creation.js
+++ b/bench/tests/element-creation.js
@@ -1,11 +1,10 @@
(function(bench) {
var svgns = 'http://www.w3.org/2000/svg'
- bench.test('svg.js: generate 10000 rects', function() {
+ bench.test('svg.js v2.3.4: generate 10000 rects', function() {
for (var i = 0; i < 10000; i++)
bench.draw.rect(100,100)
})
-
bench.test('native: generate 10000 rects', function() {
for (var i = 0; i < 10000; i++) {
var rect = document.createElementNS(svgns, 'rect')
@@ -14,12 +13,15 @@
bench.raw.appendChild(rect)
}
})
+ bench.test('Snap.svg v0.41: generate 10000 rects', function() {
+ for (var i = 0; i < 10000; i++)
+ bench.snap.rect(50, 50, 100, 100)
+ })
- bench.test('svg.js: generate 10000 rects with fill', function() {
+ bench.test('svg.js v2.3.4: generate 10000 rects with fill', function() {
for (var i = 0; i < 10000; i++)
bench.draw.rect(100,100).fill('#f06')
})
-
bench.test('native: generate 10000 rects with fill', function() {
for (var i = 0; i < 10000; i++) {
var rect = document.createElementNS(svgns, 'rect')
@@ -29,12 +31,15 @@
bench.raw.appendChild(rect)
}
})
+ bench.test('Snap.svg v0.41: generate 10000 rects with fill', function() {
+ for (var i = 0; i < 10000; i++)
+ bench.snap.rect(50, 50, 100, 100).attr('fill', '#f06')
+ })
- bench.test('svg.js: generate 10000 rects with position and fill', function() {
+ bench.test('svg.js v2.3.4: generate 10000 rects with position and fill', function() {
for (var i = 0; i < 10000; i++)
bench.draw.rect(100,100).move(50,50).fill('#f06')
})
-
bench.test('native: generate 10000 rects with position and fill', function() {
for (var i = 0; i < 10000; i++) {
var rect = document.createElementNS(svgns, 'rect')
@@ -46,5 +51,9 @@
bench.raw.appendChild(rect)
}
})
+ bench.test('Snap.svg v0.41: generate 10000 rects with fill and position', function() {
+ for (var i = 0; i < 10000; i++)
+ bench.snap.rect(50, 50, 100, 100).attr('fill', '#f06')
+ })
})(SVG.bench) \ No newline at end of file