Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
regex removing whitespace vs trim vs trimStart vs trimEnd
(version: 1)
testing removing end whitespace vs trimEnd
Comparing performance of:
regex vs trim vs trimStart vs trimEnd
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
var string = ' fsajdf asdfjosa fjoiawejf oawjfoei jaosdjfsdjfo sfjos 2324234 sdf safjao j o sdlfks dflks l '
Tests:
regex
string.replace(/\s+$/g, '')
trim
string.trim()
trimStart
string.trimStart()
trimEnd
string.trimEnd()
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
regex
trim
trimStart
trimEnd
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one month ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36 Edg/146.0.0.0
Browser/OS:
Chrome 146 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
regex
4663485.0 Ops/sec
trim
50555968.0 Ops/sec
trimStart
69943632.0 Ops/sec
trimEnd
66708440.0 Ops/sec
Related benchmarks:
Regex removing whitespace vs trim
Regex removing whitespace
Removing whitespace: regex replace vs string trim vs regex match vs regex match global
Regex removing whitespace vs trim 2
Regex removing whitespace vs trim 3
Regex removing whitespace vs trim v3
Regex whitespace remove vs trim
Regex removing whitespace vs trimEnd
Regex removing first whitespace vs trim
Comments
Confirm delete:
Do you really want to delete benchmark?