binary string to Uint8Array

Benchmark created on


Setup

let str = "ab".repeat(10000);

Test runner

Ready to run.

Testing in
TestOps/sec
fromArray
const func = x => x.codePointAt(0);
let result = Uint8Array.from(str, func)
ready
for-loop
let result = new Uint8Array(str.length);
for (let i = 0; i < str.length; ++i) {
	result[i] = str.codePointAt(i);
}
ready

Revisions

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