mirror of
https://github.com/svgdotjs/svg.js.git
synced 2024-08-30 18:00:08 +02:00
27 lines
520 B
JavaScript
27 lines
520 B
JavaScript
SVG.bench.describe('each() vs forEach()', function(bench) {
|
|
// preparation
|
|
var list = []
|
|
|
|
for (var i = 99; i >= 0; i--)
|
|
list.push(bench.draw.rect(100, 50))
|
|
|
|
var set = new SVG.Set(list)
|
|
|
|
|
|
bench.test('10000 x each()', function() {
|
|
for (var i = 0; i < 10000; i++) {
|
|
set.each(function() {
|
|
this.fill('#f06')
|
|
})
|
|
}
|
|
})
|
|
|
|
bench.test('10000 x forEach()', function() {
|
|
for (var i = 0; i < 10000; i++) {
|
|
list.forEach(function(e) {
|
|
e.fill('#f06')
|
|
})
|
|
}
|
|
})
|
|
|
|
}) |