Skip to content

Instantly share code, notes, and snippets.

@omo
Created July 16, 2013 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omo/6005479 to your computer and use it in GitHub Desktop.
Save omo/6005479 to your computer and use it in GitHub Desktop.
This demonstrates how to use window.internals.profilers API.
<!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