Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
slice VS splice VS shift for fixed size array with immutable practices
(version: 0)
Comparing performance of:
slice vs splice vs shift-while
Created:
5 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var count = 120000; var list = new Array(count).fill(100);
Tests:
slice
if (list.length > count - 1) { list=list.slice(0, count - 1) list.push(count + 1) } else { list = [...list, count + 1]; }
splice
list = [...list, count + 1] if (list.length > count) { list.splice(0, list.length - count); }
shift-while
list = [...list, count + 1] while (list.length > count) { list.shift(); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
slice
splice
shift-while
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:
Slice vs Splice vs Shift (Large Array)
Splice vs shift to remove at beginning of array (fixed from slice)
Slice vs Splice vs Shift for 1 item
Splice vs Shift to remove from the beginning
Slice vs Splice vs Shift 231
Comments
Confirm delete:
Do you really want to delete benchmark?