Add Voronoi benchmark.
This commit is contained in:
Родитель
e405e1073e
Коммит
fc73f2e43c
|
@ -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.");
|
Загрузка…
Ссылка в новой задаче