This commit is contained in:
Mike Bostock 2013-09-24 13:22:13 -07:00
Родитель e405e1073e
Коммит fc73f2e43c
1 изменённых файлов: 24 добавлений и 0 удалений

24
test/geom/voronoi-benchmark Executable file
Просмотреть файл

@ -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.");