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 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 129
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
Uint8 copyWithin
31027.5 Ops/sec
Int8 Iteration
13.4 Ops/sec
Uint32 copy within
5485.8 Ops/sec
.set
30314.2 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)