Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
immutable vs mutable, slice VS splice VS shift for fixed size arrays
(version: 0)
Comparing performance of:
slice immutable vs splice immutable vs shift-while immutable vs slice mutable vs splice mutable vs shift-while mutable
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 immutable
if (list.length > count - 1) { list=list.slice(0, count - 1) list.push(count + 1) } else { list = [...list, count + 1]; }
splice immutable
list = [...list, count + 1] if (list.length > count) { list.splice(0, list.length - count); }
shift-while immutable
list = [...list, count + 1] while (list.length > count) { list.shift(); }
slice mutable
list=list.slice(0, count) list.push(count + 1)
splice mutable
list.push(count + 1) if (list.length > count) { list.splice(0, list.length - count); }
shift-while mutable
list.push(count + 1) while (list.length > count) { list.shift(); }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (6)
Previous results
Fork
Test case name
Result
slice immutable
splice immutable
shift-while immutable
slice mutable
splice mutable
shift-while mutable
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:
Immutable Map vs Ordered Map vs List
array slice vs immutable-js takeLast
array slice vs immutable-js takeLast 3
Spread operator vs Immutable.js performance for common use cases
immutable object/set/array
Comments
Confirm delete:
Do you really want to delete benchmark?