mirror of
https://github.com/svgdotjs/svg.js.git
synced 2024-08-30 18:00:08 +02:00
36 lines
938 B
JavaScript
36 lines
938 B
JavaScript
|
|
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)
|
|
})
|
|
})
|