Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.at(i) vs Array[i]
(version: 1)
Comparing performance of:
Array.at(i) vs Array[i]
Created:
11 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const array = []; const indexes = []; const l = 999999; const iterations = 9999; for (let i = 0; i < length; ++i) { array.push(Math.random()); } for (let i = 0; i < iterations; ++i) { indexes.push(Math.floor(Math.random() * l)); }
Tests:
Array.at(i)
let total = 0; for(let i = 0; i < iterations; ++i) { const index = indexes[i]; total += array.at(index); } console.log(total);
Array[i]
let total = 0; for(let i = 0; i < iterations; ++i) { const index = indexes[i]; total += array[index]; } console.log(total);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Array.at(i)
Array[i]
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
4 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:146.0) Gecko/20100101 Firefox/146.0
Browser/OS:
Firefox 146 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Array.at(i)
134148.2 Ops/sec
Array[i]
105676.1 Ops/sec
Related benchmarks:
reduce vs loop
loops-forin-forof-native-4
array vs set index deletion
testArr insertion
sum array
Array Entries vs fori
at vs index
Splice vs new Array
??= vs manual 3
Comments
Confirm delete:
Do you really want to delete benchmark?