Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
render html/text vs. regex
(version: 1)
Comparing performance of:
regex vs parse
Created:
9 months ago
by:
Guest
Jump to the latest result
Script Preparation code:
const string = "foobar<a>Link1</a>foobar<a>Link2</a>foobar<a>Link3</a>foobar<a>Link4</a>foobar<a>Link5</a>"
Tests:
regex
string.replace(/<a>(.*?)<\/a>/g, (match, p1) => { return `<a href="/path/${p1.toLowerCase()}>${p1}</a>`; });
parse
const parser = new DOMParser(); const parsed = parser.parseFromString(string, 'text/html'); const parsedAnchors = parsed.querySelectorAll('a'); parsedAnchors.forEach((anchor) => { const content = anchor.innerHTML; anchor.setAttribute('href', `/path/${content.toLowerCase()}`); });
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
regex
parse
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
9 months ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:136.0) Gecko/20100101 Firefox/136.0
Browser/OS:
Firefox 136 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
regex
921191.4 Ops/sec
parse
17037.5 Ops/sec
Related benchmarks:
Regex Character vs Character Group
RegEx.exec vs String.match2
regexp.matchAll vs regexp.exec
A Spl vs Regx
RegExp replace vs string ops
Split vs Regex for URL Path segment check
render text/html vs. regex
DOMParser vs. regex for adding anchor-tags based on anchor-content
DOMParser vs. regex for adding anchor-tags based on anchor-content (optimised 1)
Comments
Confirm delete:
Do you really want to delete benchmark?