Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
copyWithin: is it fast?
Is copyWithin fast?
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Browser:
Chrome 128
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Uint8 copyWithin
108542.5 Ops/sec
Int8 Iteration
28.3 Ops/sec
Uint32 copy within
12380.2 Ops/sec
.set
106015.5 Ops/sec
Script Preparation code:
// starting with a plain array buffer, what is fastest? var buffer = new ArrayBuffer(1024 * 1024); var originalIntView = new Uint8Array(buffer); for (var i = 0; i < originalIntView.length; i++) { originalIntView[i] = Math.round(Math.random() * 256); }
Tests:
Uint8 copyWithin
originalIntView.copyWithin(0, 512*1024, 1024*1024)
Int8 Iteration
for (var i = 0; i < 1024 * 512; i++) { originalIntView[i] = originalIntView[i + 1024 * 512]; }
Uint32 copy within
var int32View = new Uint32Array(originalIntView.buffer, originalIntView.byteOffset, originalIntView.byteLength / 4); for (var i = 0; i < 1024 * 512 / 4; i++) { int32View[i] = int32View[i + 1024 * 512 / 4]; }
.set
var other = new Uint8Array(originalIntView.buffer, originalIntView.byteOffset + originalIntView.byteLength / 2, originalIntView.byteLength / 2) originalIntView.set(other, 0)