Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
slice vs for loop
(version: 1)
Comparing performance of:
forloop vs slice
Created:
one year ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const data = [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]; const head = 3; const tail = 4; const size = data.length; let res = [];
Tests:
forloop
for (let idx = 0; idx < size; idx++) { res.push(data[(tail + idx) % size]); }
slice
res.push(data.slice(tail)); res.push(data.slice(0, head))
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
forloop
slice
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36
Browser/OS:
Chrome 132 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
forloop
215336.3 Ops/sec
slice
86765.7 Ops/sec
Related benchmarks:
little test
Blaaaaaaaaaaaaaaargh
Last item in array Slice vs Length - 1 vs At -1
Chunk array generator(slice) vs slice vs for loop
Last item in array Slice vs Length - 1 vs .at
loop vs raw fn
3333test
for vs for of3
for vs for of5
Comments
Confirm delete:
Do you really want to delete benchmark?