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 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0
Browser:
Chrome 131
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
readUint8() with for loop
2873.6 Ops/sec
slice() with map()
120178.1 Ops/sec
slice() with Array.from()
113500.8 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);