-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbench.ts
26 lines (24 loc) · 1.18 KB
/
bench.ts
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
import fs from "fs";
import path from "path";
import Benchmark from "benchmark";
import * as sharedstreestsPbf from "./index";
const geometryBuffer = fs.readFileSync(path.join("test", "in", "11-602-769.geometry.pbf"));
const intersectionBuffer = fs.readFileSync(path.join("test", "in", "11-602-769.intersection.pbf"));
const metadataBuffer = fs.readFileSync(path.join("test", "in", "11-602-769.metadata.pbf"));
const referenceBuffer = fs.readFileSync(path.join("test", "in", "11-602-769.reference.pbf"));
/**
* Benchmark Results
*
* geometry x 1,336 ops/sec ±2.14% (85 runs sampled)
* intersection x 1,160 ops/sec ±2.98% (83 runs sampled)
* metadata x 229 ops/sec ±2.10% (82 runs sampled)
* reference x 974 ops/sec ±1.84% (88 runs sampled)
*/
const suite = new Benchmark.Suite("sharedstreets-pbf");
suite
.add("geometry", () => sharedstreestsPbf.geometry(geometryBuffer))
.add("intersection", () => sharedstreestsPbf.intersection(intersectionBuffer))
.add("metadata", () => sharedstreestsPbf.metadata(metadataBuffer))
.add("reference", () => sharedstreestsPbf.reference(referenceBuffer))
.on("cycle", (e: any) => process.stdout.write(String(e.target) + "\n"))
.run();