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()
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36
Browser:
Chrome 127
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
readUint8 with for loop
7269.0 Ops/sec
Slice with map
436898.4 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(value => Boolean(value));