uint8array (v6)

Revision 6 of this benchmark created on


Setup

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

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
4
var buffer = new Uint8Array(str.length)
for(let i = 0; i < str.length; i++) {
	buffer[i] = str.charCodeAt(i)
}
ready
5
new Uint8Array(Array.prototype.map.bind(str)(c => c.charCodeAt(0)))
ready
6
new Uint8Array(Array.from(str).map(c => c.charCodeAt(0)))
ready
7
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.