Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
manual replace vs regex replace
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:147.0) Gecko/20100101 Firefox/147.0
Browser:
Firefox 147
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 months ago
Test name
Executions per second
replace manual
11442681.0 Ops/sec
replace regex
8159211.5 Ops/sec
Script Preparation code:
String.prototype.replaceAll = function(search, replacement) { var target = this; return target.replace(new RegExp(search, 'g'), replacement); };
Tests:
replace manual
"https://www.testurl.com" .replace('www.', '') .replace('http://', '') .replace('https://', '');
replace regex
"https://www.testurl.com".replace(new RegExp(/^(https?:\/\/)?(www\.)?/, 'g'), '');