Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Uint32Array copy vs set
(version: 0)
Comparing performance of:
set vs copy
Created:
2 years ago
by:
Guest
Jump to the latest result
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]; } }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
set
copy
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
8 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:141.0) Gecko/20100101 Firefox/141.0
Browser/OS:
Firefox 141 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
set
3076388.0 Ops/sec
copy
3122404.2 Ops/sec
Related benchmarks:
copy ArrayBuffer: DataView vs Uint8Array.set vs Float64Array.set vs by bytes
copyWithin: is it fast in Uint32Array
copy ArrayBuffer: DataView vs Uint8Array.set vs Float64Array.set vs by bytes vs function
copy ArrayBuffer: Uint8Array.set vs by bytes
Comments
Confirm delete:
Do you really want to delete benchmark?