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 (Windows NT 10.0; Win64; x64; rv:141.0) Gecko/20100101 Firefox/141.0
Browser:
Firefox 141
Operating system:
Windows
Device Platform:
Desktop
Date tested:
8 months ago
Test name
Executions per second
set
3076388.0 Ops/sec
copy
3122404.2 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]; } }