Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Iterate X times
(version: 3)
Comparing performance of:
for loop vs create array to iterate with for..of
Created:
3 months ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const amountOfIterations = 1000; const doSomethingThatDoesNotNeedAccessToTheItem = () => { 1+1; }
Tests:
for loop
for(let i = 0; i < amountOfIterations; ++i) { doSomethingThatDoesNotNeedAccessToTheItem(); }
create array to iterate with for..of
const arrayToIterateOver = new Array(amountOfIterations); for (const _item of arrayToIterateOver) { doSomethingThatDoesNotNeedAccessToTheItem(); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
for loop
create array to iterate with for..of
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
3 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Browser/OS:
Chrome 143 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
for loop
462492.8 Ops/sec
create array to iterate with for..of
803834.2 Ops/sec
Related benchmarks:
Array creation
else vs continue
For i / For of / ForEach
TestArrayAllocationsAndFilling
TestArrayAllocation
TestArrayAllocationv2
if-check in loop vs two loops
javascript rulettaa
array.length === 0 vs !array.length
Comments
Confirm delete:
Do you really want to delete benchmark?