Skip to content

Commit 4b40a79

Browse files
committed
feat: benchmark on every push to master
1 parent e409a45 commit 4b40a79

File tree

4 files changed

+25
-35
lines changed

4 files changed

+25
-35
lines changed

.github/workflows/push.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,5 @@ jobs:
3232
run: yarn publish
3333
env:
3434
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
35+
36+
- uses: blacha/hyperfine-action@v1

.hyperfine.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[
2+
{"name": "Chunk Reading", "command": "node packages/core/build/__benchmark__/benchmark.js"}
3+
]

src/__benchmark__/benchmark.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { bp } from '../index.js';
2+
3+
const pkt = Buffer.from(
4+
'260400020000000001005b61646d696e6973747261746f725d00ff6339475323383a205379646e65792c4155532e20737570706f7274656420627920414345204775696c642020ff633400',
5+
'hex',
6+
);
7+
8+
const parser = bp.object('ChatMessage', {
9+
packetId: bp.u8,
10+
chatKind: bp.lu16,
11+
unk1: bp.lu16,
12+
unk2: bp.lu32,
13+
type: bp.u8,
14+
name: bp.string(),
15+
message: bp.string(),
16+
});
17+
18+
for (let i = 0; i < 100_000; i++) {
19+
parser.raw(pkt);
20+
}

src/__tests__/benchmark.test.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)