+2011-10-04 Eric Seidel <eric@webkit.org>
+
+ Update html5-full-render.html to load the HTML5 spec incrementally, closer to how the browser would
+ https://bugs.webkit.org/show_bug.cgi?id=69374
+
+ Reviewed by James Robinson.
+
+ This should finally be able to provide us with a repeatable metric
+ for how fast we're currently able to load the HTML5 spec.
+ There are a variety of interesting functions which show up in this
+ sample, including of course style resolution.
+
+ * Parser/html5-full-render.html:
+
2011-10-04 Eric Seidel <eric@webkit.org>
Update our copy of the HTML5 spec used for performance testing to match the latest version
<script>
var spec = loadFile("resources/html5.html");
-// Each iteration currently takes 30s to run on a fast machine, so we only run 2.
-start(2, function() {
- var iframe = document.createElement("iframe");
- iframe.sandbox = ''; // Prevent external script loads which could cause write() to return before completing the parse.
- document.body.appendChild(iframe);
+var chunks = [];
+// The smaller the chunks the more style resolves we do.
+// Smaller chunk sizes will show more samples in style resolution.
+// Larger chunk sizes will show more samples in line layout.
+// Smaller chunk sizes run slower overall, as the per-chunk overhead is high.
+// Testing on my machine has shown that we need 10-15 chunks before style resolution is always the top sample.
+var chunkSize = 750000; // 8mb / 750k = approx 12 chunks.
+var chunkCount = Math.ceil(spec.length / chunkSize);
+for (var chunkIndex = 0; chunkIndex < chunkCount; chunkIndex++) {
+ var chunk = spec.substring(chunkIndex * chunkSize, chunkSize);
+ chunks.push(chunk);
+}
+
+log("Testing " + spec.length + " byte document in " + chunkCount + " " + chunkSize + " byte chunks.");
+
+function loadChunkedSpecIntoIframe(iframe) {
+ // Note: We've inlined the stylesheets in html5.html. Before we did that, it seemed to be
+ // random as to whether style resolution would show up at all in the samples.
+ // Talking with Hyatt and jamesr we believe this may be the ignorePendingStylesheets
+ // logic which is triggered off of a timer which is fired after the load completes.
+ // By inlining the stylesheets we're avoiding this race condition.
+ iframe.sandbox = ''; // Prevent external loads which could cause write() to return before completing the parse.
+ iframe.style.width = "600px"; // Have a reasonable size so we're not line-breaking on every character.
+ iframe.style.height = "800px";
iframe.contentDocument.open();
- iframe.contentDocument.write(spec);
+
+ for (var chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
+ iframe.contentDocument.write(chunks[chunkIndex]);
+ // Note that we won't cause a style resolve until we've encountered the <body> element.
+ // Thus the number of chunks counted above is not exactly equal to the number of style resolves.
+ if (iframe.contentDocument.body)
+ iframe.contentDocument.body.clientHeight; // Force a full style-resolve.
+ }
+
iframe.contentDocument.close();
- iframe.contentDocument.body.clientHeight; // Force a full style-resolve.
- document.body.removeChild(iframe);
-});
+}
+
+// Running from the onload callback just makes the UI nicer as it shows the logs before starting the test.
+window.onload = function() {
+ // Depending on the chosen chunk size, iterations can take over 60s to run on a fast machine, so we only run 2.
+ start(2, function() {
+ var iframe = document.createElement("iframe");
+ document.body.appendChild(iframe);
+ loadChunkedSpecIntoIframe(iframe);
+ document.body.removeChild(iframe);
+ }, 1); // We only loop once for each run, again because this test is so slow.
+}
+
</script>
</body>