Skip to content

Commit 5be05ae

Browse files
committed
add a rudimentary benchmark
1 parent af22b34 commit 5be05ae

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

bench.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import match from './index.js';
2+
import {PNG} from 'pngjs';
3+
import fs from 'fs';
4+
5+
const data = [1, 2, 3, 4, 5, 6, 7].map(i => [
6+
readImage(`${i}a`),
7+
readImage(`${i}b`)
8+
]);
9+
10+
console.time('match');
11+
let sum = 0;
12+
for (let i = 0; i < 100; i++) {
13+
for (const [img1, img2] of data) {
14+
sum += match(img1.data, img2.data, null, img1.width, img1.height);
15+
}
16+
}
17+
console.timeEnd('match');
18+
console.log(sum);
19+
20+
function readImage(name) {
21+
return PNG.sync.read(fs.readFileSync(new URL(`test/fixtures/${name}.png`, import.meta.url)));
22+
}

0 commit comments

Comments
 (0)