Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
String slice vs. array slicee
(version: 0)
Comparing performance of:
String concat vs Array spread vs Array with concat
Created:
2 years ago
by:
Guest
Jump to the latest result
Tests:
String concat
var arr = new Map() let prev="" for (let i = 0;i<10000;++i){ prev+="ABC:"; arr.set(+i,prev); } function process(s){ return s.slice(0,s.lastIndexOf(':')) } for (const [key,value] of arr){ arr.delete(key) }
Array spread
var arr = new Map() let prev=[] for (let i = 0;i<10000;++i){ prev =[...prev, 'ABC'] arr.set(+i,prev); } function process(s){ return s.slice(0,s.length-1) } for (const [key,value] of arr){ arr.delete(key) }
Array with concat
var arr = new Map() let prev=[] for (let i = 0;i<10000;++i){ prev = prev.concat('ABC') arr.set(+i,prev); } function process(s){ return s.slice(0,s.length-1) } for (const [key,value] of arr){ arr.delete(key) } console.log("hello")
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
String concat
Array spread
Array with concat
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
`Array.slice(-1)[0]` vs `Array[Array.length]`
arr.slice(-1)[0] vs arr[arr.length - 1]
Slice vs Split (for title names)
array from string and slice or substring and array from shorter string
Comments
Confirm delete:
Do you really want to delete benchmark?