From b8ab3ad3ef7379ed50cbdbf9feb46ed0bbd1b04d Mon Sep 17 00:00:00 2001 From: Jason Davies Date: Thu, 13 Dec 2012 10:57:38 +0000 Subject: [PATCH] Benchmark U.S. counties. This is useful to see how fast we can process polygons that don't intersect with the clip edge. --- test/geo/benchmark.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/test/geo/benchmark.js b/test/geo/benchmark.js index 955f76fa..08468fdf 100644 --- a/test/geo/benchmark.js +++ b/test/geo/benchmark.js @@ -1,14 +1,27 @@ require("../env"); +var fs = require("fs"); + var formatNumber = d3.format(",.02r"), projection = d3.geo.stereographic().clipAngle(150), path = d3.geo.path().projection(projection), graticule = d3.geo.graticule().step([1, 1]), circle = d3.geo.circle().angle(30), - n = 10; + n = 10, + o, + then; -var o = graticule(), - then = Date.now(); +o = JSON.parse(fs.readFileSync("./examples/data/us-counties.json")); +then = Date.now(); + +for (var i = 0, k = 0; i < n; i++, k++) { + path(o); +} + +console.log("U.S. counties: " + formatNumber((Date.now() - then) / k) + "ms/op."); + +o = graticule(); +then = Date.now(); for (var i = 0, k = 0; i < n; i++, k++) { path(o);