Skip to content

Commit

Permalink
Add Voronoi benchmark.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Oct 5, 2013
1 parent e405e10 commit fc73f2e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/geom/voronoi-benchmark
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node

var d3 = require("../../");

var width = 960,
height = 500;

var points = d3.range(10000).map(function() {
return [Math.random() * width, Math.random() * height];
});

var voronoi = d3.geom.voronoi()
.clipExtent([[0, 0], [width, height]]);

var observations = d3.range(20).map(function() {
process.stdout.write(".");
var start = process.hrtime();
voronoi(points);
var elapsed = process.hrtime(start);
return elapsed[0] * 1e3 + elapsed[1] / 1e6;
});

console.log("");
console.log(Math.round(d3.mean(observations)) + "ms for 10,000 points.");

0 comments on commit fc73f2e

Please sign in to comment.