Skip to content

Commit

Permalink
Use DataView instead of Buffer in hand-written benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
screeny05 committed Nov 22, 2023
1 parent b99ae40 commit 215959f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions benchmark/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,14 @@ for (let i = 0; i < n; i++) {
// Run benchmarks
suite
.add("hand-written", function () {
const n = buf.readUInt32LE(0);
const view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
const n = view.getUint32(0, true);
const points = [];
for (let i = 0; i < n; i++) {
points.push({
x: buf.readUInt16LE(i * 6 + 0 + 4),
y: buf.readUInt16LE(i * 6 + 2 + 4),
z: buf.readUInt16LE(i * 6 + 4 + 4),
x: view.getUint16(i * 6 + 0 + 4, true),
y: view.getUint16(i * 6 + 2 + 4, true),
z: view.getUint16(i * 6 + 4 + 4, true),
});
}
})
Expand Down

0 comments on commit 215959f

Please sign in to comment.