Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
1d to 2d array - for i vs while splice
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/133.0.0.0 Safari/537.36
Browser:
Chrome 133
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
for i; += 2
267900.2 Ops/sec
while splice
137850464.0 Ops/sec
Script Preparation code:
arr = []; for (i=0; i<1024; i++) { arr.push(i); } arr2 = []; for (i=0; i<1024; i++) { arr2.push(i); }
Tests:
for i; += 2
var pairs = []; for (let i = 0; i < arr.length - 1; i += 2) { pairs.push([arr[i], arr[i + 1]]); }
while splice
var pairs = []; while(arr2.length) pairs.push(arr2.splice(0,2));