Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
for w/length constant vs foreach vs some vs for..of (2)
Compare loop performance
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/120.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 120
Operating system:
Android
Device Platform:
Mobile
Date tested:
2 years ago
Test name
Executions per second
for (lenght 另外儲存)
100054.8 Ops/sec
foreach with operation
2622744.2 Ops/sec
some
2649084.8 Ops/sec
for..of
79935.0 Ops/sec
for (lenght 不另外儲存)
49891.4 Ops/sec
Script Preparation code:
var array = new Array(100);
Tests:
for (lenght 另外儲存)
const length = array.length for (var i = 0; i < length; i++) { array[i]; }
foreach with operation
array.forEach(function(i) { array[i]; });
some
array.some(function(i) { array[i]; });
for..of
for (var i of array) { array[i]; }
for (lenght 不另外儲存)
for (var i = 0; i < array.length; i++) { array[i]; }