Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
CleanVsDirty
(version: 1)
Comparing performance of:
Dirty vs Clean
Created:
11 months ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<!--your preparation HTML code goes here-->
Script Preparation code:
/*your preparation JavaScript code goes here To execute async code during the script preparation, wrap it as function globalMeasureThatScriptPrepareFunction, example:*/ async function globalMeasureThatScriptPrepareFunction() { // This function is optional, feel free to remove it. // await someThing(); }
Tests:
Dirty
printHtmlContent = (htmlContent) => { const iframe = document.createElement("iframe"); iframe.style.display = "none"; document.body.appendChild(iframe); iframe.contentWindow.addEventListener("afterprint", () => { document.body.removeChild(iframe); }); // Add CSS to remove headers and footers const cssToRemoveHeadersAndFooters = `<style> @page { margin: 0; size: auto; } @media print { body { margin: 0; padding: 0; } } </style> `; iframe.contentWindow.document.open(); iframe.contentWindow.document.write(cssToRemoveHeadersAndFooters + htmlContent); iframe.contentWindow.document.close(); iframe.contentWindow.focus(); }; printHtmlContent('<div>Hello, World</div>');
Clean
printHtmlContent = (htmlContent) => { const createTemporaryIframe = () => { const iframe = document.createElement("iframe"); iframe.style.display = "none"; document.body.appendChild(iframe); return iframe; }; const writeToIframe = (iframe, content) => { iframe.contentWindow.document.open(); iframe.contentWindow.document.write(content); iframe.contentWindow.document.close(); }; const addPrintEventListeners = (iframe) => { iframe.contentWindow.addEventListener("afterprint", () => { document.body.removeChild(iframe); }); }; const printIframe = (iframe) => { iframe.contentWindow.focus(); }; // Add CSS to remove headers and footers const cssToRemoveHeadersAndFooters = ` <style> @page { margin: 0; size: auto; } @media print { body { margin: 0; padding: 0; } } </style> `; const iframe = createTemporaryIframe(); writeToIframe(iframe, cssToRemoveHeadersAndFooters + htmlContent); addPrintEventListeners(iframe); printIframe(iframe); }; printHtmlContent('<div>Hello, World</div>');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Dirty
Clean
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
11 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0
Browser/OS:
Firefox 139 on Mac OS X 10.15
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Dirty
161.3 Ops/sec
Clean
133.9 Ops/sec
Related benchmarks:
Luxon vs
undefined to boolean
testingqueries
test early return
Multiple .closest() or complex CSS selector
Query Element
dsDOM vs JQuery
set: innerHTML vs outerHTML
createElement vs DOMParser
Comments
Confirm delete:
Do you really want to delete benchmark?