Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
sadsadsadsa
(version: 0)
Comparing performance of:
split-join vs regex vs loop vs function
Created:
5 years ago
by:
Guest
Jump to the latest result
Tests:
split-join
'Abcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxyAbcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxy'.split('\t').join(' ');
regex
'Abcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxyAbcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxy'.replace(new RegExp('\t', 'g'), ' ');
loop
let str = 'Abcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxyAbcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxy' let res = ''; for (let i = 0; i < str.length; i++) { if (str.charAt(i) === '\t' ) { res += ' '; } else { res += str.charAt(i); } }
function
'Abcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxyAbcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxy\tAbcd\tefghij\tklmnopqrstuv\twxy'.replaceAll('\t', ' ');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
split-join
regex
loop
function
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:
Iterating over string
matchAll vs exec
matchAll vs exec v2
replace vs exec v2
String slice: full vs chunk
Comments
Confirm delete:
Do you really want to delete benchmark?