x

Benchmark created on


Setup

const inp = "\x01".repeat(1e6);

Test runner

Ready to run.

Testing in
TestOps/sec
a
const out = Uint8Array.from(inp, v=>v.charCodeAt(0));
ready
b
const out = new Uint8Array(inp.length);
for (let i = 0, ii = inp.length; i<ii; i++) out[i] = inp.charCodeAt(i);
ready
c
const out = new Uint8Array(inp.length);
for (let i = 0, ii = inp.length; i<ii; i++) out[i] = inp[i].charCodeAt(0);
ready
d
const out = new Uint8Array(inp.length);
for (let i = 0, ii = inp.length; i<ii; i++) out[i] = inp.codePointAt(i);
ready
e
const out = new Uint8Array(inp.length).map((_,i)=>inp.charCodeAt(i));
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.