Skip to content

Commit f2267c0

Browse files
committed
feat: improve continous benchmarks
1 parent eafa59c commit f2267c0

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

.hyperfine.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
[
2-
{"name": "Reading Complex", "command": "node build/src/__benchmark__/benchmark.complex.js"},
3-
{"name": "Reading UInt", "command": "node build/src/__benchmark__/benchmark.int.js"}
2+
{"name": "Packet", "command": "node build/src/__benchmark__/benchmark.packet.js"},
3+
{"name": "UInt", "command": "node build/src/__benchmark__/benchmark.int.js"},
4+
{"name": "Array", "command": "node build/src/__benchmark__/benchmark.array.js"}
5+
46
]
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { bp } from '../index.js';
2+
3+
const PointParser = bp.object('Point', {
4+
x: bp.lu16,
5+
y: bp.lu16,
6+
});
7+
8+
const PointsParser = bp.object('SimpleObject', {
9+
length: bp.variable('len', bp.lu32),
10+
points: bp.array('Points', PointParser, 'len'),
11+
});
12+
13+
const n = 1000;
14+
const buf = Buffer.alloc(4 + n * 2 * 2);
15+
16+
buf.writeUInt32LE(n, 0);
17+
for (let i = 0; i < n; i++) {
18+
buf.writeUInt16LE(123, i * 4);
19+
buf.writeUInt16LE(456, i * 4 + 2);
20+
}
21+
22+
for (let i = 0; i < 1_000_000; i++) {
23+
PointsParser.raw(buf);
24+
}

0 commit comments

Comments
 (0)