Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Binary to boolean with DataView: readUint8() with for loop vs. slice() with map() vs. slice() with Array.from()
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 128
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
readUint8() with for loop
3108.7 Ops/sec
slice() with map()
142283.5 Ops/sec
slice() with Array.from()
113012.0 Ops/sec
Tests:
readUint8() with for loop
const length = 1000; const arrayBuffer = new ArrayBuffer(length); const array = new Uint8Array(arrayBuffer); for (let i = 0; i < length; i++) { array[i] = 22; } const dataView = new DataView(arrayBuffer); const resultArray = []; for (let i = 0; i < length; i++) { const value = dataView.getUint8(i); resultArray.push(Boolean(value)); }
slice() with map()
const length = 1000; const arrayBuffer = new ArrayBuffer(length); const array = new Uint8Array(arrayBuffer); for (let i = 0; i < length; i++) { array[i] = 22; } const dataView = new DataView(arrayBuffer); const transferArray = new Uint8Array(dataView); const resultArray = [...transferArray].map(Boolean);
slice() with Array.from()
const length = 1000; const arrayBuffer = new ArrayBuffer(length); const array = new Uint8Array(arrayBuffer); for (let i = 0; i < length; i++) { array[i] = 22; } const dataView = new DataView(arrayBuffer); const transferArray = new Uint8Array(dataView); const resultArray = Array.from(transferArray, Boolean);