-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
53 lines (50 loc) · 1.64 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var s2Cover = require('geojson-cover'),
tileCover = require('tile-cover'),
queue = require('queue-async'),
Benchmark = require('benchmark'),
fs = require('fs');
global.tileCover = tileCover;
global.s2Cover = s2Cover;
global.fs = fs;
function testData(file, callback) {
console.log('\n' + file + '\n');
global.file = file;
var suite = new Benchmark.Suite(file);
suite
.add({
name: 'tileCover.indexes',
fn: function() {
counties.features.forEach(function(county){
global.tileCover.indexes(county.geometry, {min_zoom:1, max_zoom: 9})
});
},
setup: function() {
var counties = JSON.parse(global.fs.readFileSync(global.file));
counties.features = counties.features.slice(0, 2)
}
})
.add({
name: 's2.indexes',
fn: function() {
counties.features.forEach(function(county){
global.s2Cover.geometryIndexes(county.geometry, {index_min_level: 1, index_max_level: 10, max_index_cells: 50000000})
});
},
setup: function() {
var counties = JSON.parse(global.fs.readFileSync(global.file));
counties.features = counties.features.slice(0, 2)
}
})
.on('cycle', function(event) {
console.log(String(event.target));
})
.on('complete', function() {
console.log('Fastest is ' + this.filter('fastest').pluck('name'));
callback();
})
.run();
}
queue(1)
.defer(testData, './fixtures/dc_fountains.geojson')
.defer(testData, './fixtures/multipoint.geojson')
.defer(testData, './fixtures/counties.geojson');