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 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0
Browser:
Firefox 146
Operating system:
Windows
Device Platform:
Desktop
Date tested:
7 months ago
.set
43K/s
Uint8 copyWithin
40K/s
Uint32 copy within
4K/s
Int8 Iteration
2K/s
View exact numbers
Test name
Executions per second
✓
.set
42,909 Ops/sec
Uint8 copyWithin
40,292 Ops/sec
Uint32 copy within
3,997 Ops/sec
Int8 Iteration
1,516 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)