Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
RegExp search and replace vs URL and searchParams delete
(version: 1)
Comparing performance of:
Deletion with Url constructor and search params vs Deletion with RegExp and replace
Created:
one year ago
by:
Registered User
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
var location_href = "https://www.youtube.com/watch?v=x2rvSf0STBM&list=RDCLAK5uy_kvhjcPWzH7xZL-WnqGbiA_euQGy5_cbHI&start_radio=1"; var location_search = "?v=x2rvSf0STBM&list=RDCLAK5uy_kvhjcPWzH7xZL-WnqGbiA_euQGy5_cbHI&start_radio=1"; var loop = 10000; var loop_n = 3000; var urls = new Array(loop_n).fill(0).map(()=>{ let t = Math.round(Math.random()*80000+10000); return { href: `${location_href}${t}`, search: `${location_search}${t}` }; })
Tests:
Deletion with Url constructor and search params
for(let i=loop_n;--i;){ new URL(urls[i].href).searchParams.delete("start_radio"); }
Deletion with RegExp and replace
for(let i=loop_n;--i;){ const regex = new RegExp('[?|&]start_radio=\\d', ''); urls[i].href.replace(regex, '') }
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Deletion with Url constructor and search params
Deletion with RegExp and replace
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/131.0.0.0 Safari/537.36
Browser/OS:
Chrome 131 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Deletion with Url constructor and search params
143.5 Ops/sec
Deletion with RegExp and replace
3467.1 Ops/sec
Related benchmarks:
birirbibir
Regex vs .startsWith vs .indexOf vs .substr on string length 2000
Regex vs endsWith vs indexOf vs lastIndexOf
charAt vs indexOf
URL vs URLSearchParams vs RegExp
JS Regex with OR (url) vs .startsWith
mybencmark11212224234
mybencmark1121222423412
JS Regex vs .startsWith vs .indexOf long
Comments
Confirm delete:
Do you really want to delete benchmark?