Skip to content

Commit

Permalink
Add uint8array concat benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
wemeetagain committed Dec 3, 2022
1 parent 65b1de2 commit f9d856f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion packages/beacon-node/test/perf/util/bytes.test.ts
Expand Up @@ -17,6 +17,21 @@ describe("bytes utils", function () {
fn: () => {
Buffer.concat(buffers);
},
runsFactor: 1000,
});

itBench({
id: `Uint8Array.set ${count} items`,
fn: () => {
let size = 0;
for (const b of buffers) {
size += b.length;
}
const arr = new Uint8Array(size);
let offset = 0;
for (const b of buffers) {
arr.set(b, offset);
offset += b.length;
}
},
});
});

0 comments on commit f9d856f

Please sign in to comment.