Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
this is a little trim test
(version: 1)
Comparing performance of:
Multiple, regex vs Trim at last vs Trim at first
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var str = " Et inventore ut est. Illum dolorem similique odit. Velit necessitatibus unde nostrum sequi ut pariatur suscipit sit magnam. Cum esse sed quod aut id. Recusandae vel commodi."
Tests:
Multiple, regex
str = str.replace(/a/g, 'A').replace(/e/g,'E')
Trim at last
str = str.replace(/a|e/g, match => match === 'a' ? 'A' : 'B').trim()
Trim at first
str = str.trim().replace(/a|e/g, match => match === 'a' ? 'A' : 'B')
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Multiple, regex
Trim at last
Trim at first
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36
Browser/OS:
Chrome 136 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Multiple, regex
3407307.0 Ops/sec
Trim at last
4386072.0 Ops/sec
Trim at first
1264763.5 Ops/sec
Related benchmarks:
Single vs multiple regex replace calls
Regex lookarounds
regex vs trim test
ReplaceAll
ReplaceAll (regular expression, native API, split and join)
replaceAll vs regex replace pt2
replaceAll vs regex replace pt3
regex vs string replaceAll
Single vs multiple regex replace calls new new
Comments
Confirm delete:
Do you really want to delete benchmark?