Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
test DomParser vs Regex vs IndexIf
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:137.0) Gecko/20100101 Firefox/137.0
Browser:
Firefox 137
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Dom Parser
46955.8 Ops/sec
Regex
4788063.5 Ops/sec
Loop
136955360.0 Ops/sec
Tests:
Dom Parser
const html = "<html><body><div>test</div></body></html>"; const parser = new DOMParser(); const virtualDom = parser.parseFromString(html, 'text/html'); const body = virtualDom.querySelector('body');
Regex
const html = "<html><body><div>test</div></body></html>"; const pattern = /<body[^>]*>((.|[\n\r])*)<\/body>/im; const matches = pattern.exec(html); const body = matches[1];
Loop
const html = "<html><body><div>test</div></body></html>"; const start = html.indexOf('>') + 1; const end = html.lastIndexOf('</'); const body = html.slice(start, end);