Skip to content

Commit 215959f

Browse files
committed
Use DataView instead of Buffer in hand-written benchmark
1 parent b99ae40 commit 215959f

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

benchmark/bench.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,14 @@ for (let i = 0; i < n; i++) {
6464
// Run benchmarks
6565
suite
6666
.add("hand-written", function () {
67-
const n = buf.readUInt32LE(0);
67+
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
68+
const n = view.getUint32(0, true);
6869
const points = [];
6970
for (let i = 0; i < n; i++) {
7071
points.push({
71-
x: buf.readUInt16LE(i * 6 + 0 + 4),
72-
y: buf.readUInt16LE(i * 6 + 2 + 4),
73-
z: buf.readUInt16LE(i * 6 + 4 + 4),
72+
x: view.getUint16(i * 6 + 0 + 4, true),
73+
y: view.getUint16(i * 6 + 2 + 4, true),
74+
z: view.getUint16(i * 6 + 4 + 4, true),
7475
});
7576
}
7677
})

0 commit comments

Comments
 (0)