uint8array (v3)

Revision 3 of this benchmark created on


Setup

window.str = 'a'.repeat(9999999)

Test runner

Ready to run.

Testing in
TestOps/sec
1
var arr = str.split('')
new Uint8Array(arr.map(c => c.charCodeAt(0)))
ready
2
var arr = str.split('')
var buffer = new Uint8Array(arr.length)
for(let i = 0; i < arr.length; i++) {
	buffer[i] = arr[i].charCodeAt(0)
}
ready
3
var buffer = new Uint8Array(str.length)
new TextEncoder().encodeInto(str, buffer)
ready

Revisions

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