summaryrefslogtreecommitdiffstats
path: root/bench/tests/10000-circles.js
blob: 28fd6093382994476572914e6002e6a18d5f20e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
SVG.bench.describe('Generate 10000 circles', function(bench) {
  bench.test('using SVG.js v2.5.2', function() {
    for (var i = 0; i < 10000; i++)
      bench.draw.circle(100,100)
  })
  bench.test('using vanilla js', function() {
    for (var i = 0; i < 10000; i++) {
      var circle = document.createElementNS(SVG.ns, 'circle')
      circle.setAttributeNS(null, 'rx', 50)
      circle.setAttributeNS(null, 'ry', 50)
      bench.raw.appendChild(circle)
    }
  })
  bench.test('using Snap.svg v0.5.1', function() {
    for (var i = 0; i < 10000; i++)
      bench.snap.circle(50, 50, 100, 100)
  })
})

SVG.bench.describe('Generate 10000 circles with fill', function(bench) {
  bench.test('using SVG.js v2.5.2', function() {
    for (var i = 0; i < 10000; i++)
      bench.draw.circle(100,100).fill('#f06')
  })
  bench.test('using vanilla js', function() {
    for (var i = 0; i < 10000; i++) {
      var circle = document.createElementNS(SVG.ns, 'circle')
      circle.setAttributeNS(null, 'rx', 50)
      circle.setAttributeNS(null, 'ry', 50)
      circle.setAttributeNS(null, 'fill', '#f06')
      bench.raw.appendChild(circle)
    }
  })
  bench.test('using Snap.svg v0.5.1', function() {
    for (var i = 0; i < 10000; i++)
      bench.snap.circle(50, 50, 100, 100).attr('fill', '#f06')
  })
})