Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Uint32Array copy vs set
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/121.0.0.0 Safari/537.36
Browser:
Chrome 121
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
set
949783.4 Ops/sec
copy
897629.8 Ops/sec
Script Preparation code:
var command = Math.floor(Math.random() * 65536), operation = Math.floor(Math.random() * 65536), cellId = Math.floor(Math.random() * 60), buffer = new Uint8Array(Array.from({ length: Math.floor(Math.random() * 100) }).map(() => Math.floor(Math.random() * 256))).buffer, reverse = [0, 3], HEADER_SIZE = 8, MSG_HEADER_LEN = 32;
Tests:
set
const dataLength = buffer.byteLength; const content = new ArrayBuffer(MSG_HEADER_LEN + dataLength); const contentView = new Uint32Array(content, 0, HEADER_SIZE); if (dataLength) { const srcBuffer = new Uint8Array(buffer); const dstBuffer = new Uint8Array(content); dstBuffer.set(srcBuffer, MSG_HEADER_LEN); }
copy
const dataLength = buffer.byteLength; const content = new ArrayBuffer(MSG_HEADER_LEN + dataLength); const contentView = new Uint32Array(content, 0, HEADER_SIZE); if (dataLength) { const srcBuffer = new Uint8Array(buffer); const dstBuffer = new Uint8Array(content, MSG_HEADER_LEN, dataLength); for (let index = 0; index < dataLength; index++) { dstBuffer[index] = srcBuffer[index]; } }