Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@ jobs:
node:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v1
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 20

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test
node-version: 24
cache: npm
- run: npm ci
- run: npm test
24 changes: 24 additions & 0 deletions bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import polylabel from './polylabel.js';
import water1 from './test/fixtures/water1.json' with {type: 'json'};
import water2 from './test/fixtures/water2.json' with {type: 'json'};

const cases = [
['water1 precision 1', water1, 1],
['water1 precision 50', water1, 50],
['water2 precision 1', water2, 1],
];

const RUNS = 100;

for (const [name, polygon, precision] of cases) {
const times = [];
for (let r = 0; r < RUNS; r++) {
const t = performance.now();
polylabel(polygon, precision);
times.push(performance.now() - t);
}
times.sort((a, b) => a - b);
const min = times[0];
const median = times[times.length >> 1];
console.log(`${name}: min ${min.toFixed(2)}ms, median ${median.toFixed(2)}ms`);
}
13 changes: 0 additions & 13 deletions debug.js

This file was deleted.

Loading