Skip to content

Commit fc73f2e

Browse files
committed
Add Voronoi benchmark.
1 parent e405e10 commit fc73f2e

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

test/geom/voronoi-benchmark

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env node
2+
3+
var d3 = require("../../");
4+
5+
var width = 960,
6+
height = 500;
7+
8+
var points = d3.range(10000).map(function() {
9+
return [Math.random() * width, Math.random() * height];
10+
});
11+
12+
var voronoi = d3.geom.voronoi()
13+
.clipExtent([[0, 0], [width, height]]);
14+
15+
var observations = d3.range(20).map(function() {
16+
process.stdout.write(".");
17+
var start = process.hrtime();
18+
voronoi(points);
19+
var elapsed = process.hrtime(start);
20+
return elapsed[0] * 1e3 + elapsed[1] / 1e6;
21+
});
22+
23+
console.log("");
24+
console.log(Math.round(d3.mean(observations)) + "ms for 10,000 points.");

0 commit comments

Comments
 (0)