, _before: function() {}
, _after: function() {}
, draw: SVG('draw')
+ , snap: Snap(100, 100)
, raw: document.getElementById('native')
// Add test
, 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)
while(this.raw.hasChildNodes())
this.raw.removeChild(this.raw.lastChild)
this.draw.clear()
+ this.snap.clear()
}
}
(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')
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')
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')
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