-
Notifications
You must be signed in to change notification settings - Fork 930
/
bench.js
32 lines (29 loc) · 975 Bytes
/
bench.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
const fs = require('fs');
const path = require('path');
const load = require('load-json-file');
const Benchmark = require('benchmark');
const lineOverlap = require('./').default;
const directory = path.join(__dirname, 'test', 'in') + path.sep;
const fixtures = fs.readdirSync(directory).map(filename => {
return {
filename,
name: path.parse(filename).name,
geojson: load.sync(directory + filename)
};
});
/**
* Benchmark Results
*
* polygons x 3,567 ops/sec ±1.61% (85 runs sampled)
* simple1 x 9,013 ops/sec ±1.15% (86 runs sampled)
* simple2 x 10,278 ops/sec ±1.52% (86 runs sampled)
* simple3 x 13,124 ops/sec ±1.37% (85 runs sampled)
*/
const suite = new Benchmark.Suite('turf-line-overlap');
for (const {name, geojson} of fixtures) {
suite.add(name, () => lineOverlap(geojson.features[0], geojson.features[1]));
}
suite
.on('cycle', e => { console.log(String(e.target)); })
.on('complete', () => {})
.run();