Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
html encode
(version: 0)
Comparing performance of:
replaceAllWithShortcut vs serializeTextNode
Created:
one year ago
by:
Guest
Jump to the latest result
Script Preparation code:
function replaceAllWithShortcut(str) { return !(/[<>&"']/.test(str)) ? str : str.replaceAll('&', '&').replaceAll('<', '<') .replaceAll('>', '>').replaceAll('"', '"'); } const cachedElementParent = document.createElement('div'); const cachedChildTextNode = document.createTextNode(''); cachedElementParent.appendChild(cachedChildTextNode); function serializeTextNode(text) { cachedChildTextNode.nodeValue = text; return cachedElementParent.innerHTML; }
Tests:
replaceAllWithShortcut
replaceAllWithShortcut("hello <script>alert('xss')</script>")
serializeTextNode
serializeTextNode("hello <script>alert('xss')</script>")
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
replaceAllWithShortcut
serializeTextNode
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?