Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
substring vs slice on string
(version: 1)
Comparing performance of:
substring vs slice
Created:
one month ago
by:
Guest
Go to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
const id = '123818727033' const id_with = '123818727033_2'
Tests:
substring
/*When writing async/deferred tests, use `deferred.resolve()` to mark test as done*/ const base1 = id.substring(0,12) const base2 = id_with.substring(0,12)
slice
const base1 = id.slice(0,12) const base2 = id_with.slice(0,12)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
substring
slice
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36
Browser/OS:
Chrome 149 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
slice
232.4M/s
substring
231.6M/s
View exact numbers
Test name
Executions per second
✓
slice
232,395,440 Ops/sec
substring
231,623,120 Ops/sec
Related benchmarks
slice vs substr vs substring (with no end index) big string
slice vs split vs substring (with start and end)
slice vs substring vs [] vs charAt vs charCodeAt
Comments
Confirm delete:
Do you really want to delete benchmark?