Title: [96647] trunk/PerformanceTests
Revision
96647
Author
[email protected]
Date
2011-10-04 14:27:03 -0700 (Tue, 04 Oct 2011)

Log Message

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:

Modified Paths

Diff

Modified: trunk/PerformanceTests/ChangeLog (96646 => 96647)


--- trunk/PerformanceTests/ChangeLog	2011-10-04 21:25:27 UTC (rev 96646)
+++ trunk/PerformanceTests/ChangeLog	2011-10-04 21:27:03 UTC (rev 96647)
@@ -1,5 +1,19 @@
 2011-10-04  Eric Seidel  <[email protected]>
 
+        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  <[email protected]>
+
         Update our copy of the HTML5 spec used for performance testing to match the latest version
         https://bugs.webkit.org/show_bug.cgi?id=69364
 

Modified: trunk/PerformanceTests/Parser/html5-full-render.html (96646 => 96647)


--- trunk/PerformanceTests/Parser/html5-full-render.html	2011-10-04 21:25:27 UTC (rev 96646)
+++ trunk/PerformanceTests/Parser/html5-full-render.html	2011-10-04 21:27:03 UTC (rev 96647)
@@ -5,16 +5,53 @@
 <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>
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to