Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Split vs Substring + IndexOf
(version: 1)
Comparing performance of:
Split vs Substring
Created:
one year ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<div id='xx'></div>
Script Preparation code:
let email = 'TestUser2137@example.com'; let times = 1000;
Tests:
Split
let x = 0; while (x < times) { const userName = email.split('@')[0]; console.log(userName); x += 1; }
Substring
let x = 0; while (x < times) { const userName = email.substring(0, email.indexOf('@')); console.log(userName); x += 1; }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Split
Substring
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
8 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36 Edg/139.0.0.0
Browser/OS:
Chrome 139 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Split
531.5 Ops/sec
Substring
533.3 Ops/sec
Related benchmarks:
Testing lastIndexOf vs split+pop
regexp vs split 6
Concatenation vs substring
Concatenation vs Find and Substring
Split vs substring: parse string of many values
Skip Substr if length is less
lastIndexOf vs split
split vs splitstring
Split: Set size vs Every 2
Comments
Confirm delete:
Do you really want to delete benchmark?