Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Iterator vs Index for loop (cached array length fixed)
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/133.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 133
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
Iterator for loop
15357.6 Ops/sec
Index for loop
14405.9 Ops/sec
Script Preparation code:
var arr = []; for(let i = 0; i < 10000; i++) { arr.push(Math.random()); } var arrLength = arr.length;
Tests:
Iterator for loop
let sum = 0; for(const num of arr) { sum += num; }
Index for loop
let sum = 0; for(let i = 0; i < arrLength; i++) { sum += arr[i]; }