Uint8Array from binary string: .from vs loop

Benchmark created on


Setup

const binString = '1234567890';

Test runner

Ready to run.

Testing in
TestOps/sec
Loop
let len = binString.length;
const arr = new Uint8Array(len);
while (len--) {
	arr[len] = binString.charCodeAt(len);
}
ready
.from
const arr = Uint8Array.from(binString, c => c.charCodeAt())
ready

Revisions

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