Created
July 16, 2013 03:14
-
-
Save omo/6005479 to your computer and use it in GitHub Desktop.
This demonstrates how to use window.internals.profilers API.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!HTML> | |
<html> | |
<head></head> | |
<body> | |
<script> | |
function parseProfileHeader(text) | |
{ | |
return parseInt(text.match(/(\d+) \[/)[1]); | |
} | |
window.testRunner.dumpAsText(); | |
window.internals.profilers.startHeapProfiling("hello"); | |
var before = window.internals.profilers.getHeapProfile(); | |
var documents = []; | |
for (var i = 0; i < 1000; i++) { | |
documents.push(document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null)); | |
//documents.push(document.createElement("div")); | |
} | |
after = window.internals.profilers.getHeapProfile(); | |
beforeBytes = parseProfileHeader(before); | |
afterBytes = parseProfileHeader(after); | |
var deltakb = (afterBytes - beforeBytes)/1024.0; | |
console.log(before) | |
console.log(after); | |
console.log("Delta is: " + deltakb + " KB"); | |
window.internals.profilers.stopHeapProfiling(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment