Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Testing array lookup vs storing it in a variable first
(version: 0)
Comparing performance of:
as i vs as vari
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var arr = new Array(100_000) for (let i=0; i< 100_000; ++i) { arr[i] = { x1: Math.random(), x2: Math.random(), x3: Math.random(), x4: Math.random(), x5: Math.random() } }
Tests:
as i
for (let i=0; i< arr.length; ++i) { arr[i].x1 += 10 arr[i].x2 += 10 arr[i].x3 += 10 arr[i].x4 += 10 arr[i].x5 += 10 }
as vari
for (let i=0; i< arr.length; ++i) { let iter = arr[i] iter.x1 += 10 iter.x2 += 10 iter.x3 += 10 iter.x4 += 10 iter.x5 += 10 }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
as i
as vari
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Related benchmarks:
findIndex vs indexOf for simple array 2
object[]: findIndex vs for loop with more complex condition check
Object arrays: findIndex vs for loop2
Object arrays: findIndex vs for loop (length cached)
Object arrays: findIndex vs for loop vs some
Comments
Confirm delete:
Do you really want to delete benchmark?