3 <script src="../resources/runner.js"></script>
5 var spec = PerfTestRunner.loadFile("resources/html5.html");
8 // The smaller the chunks the more style resolves we do.
9 // Smaller chunk sizes will show more samples in style resolution.
10 // Larger chunk sizes will show more samples in line layout.
11 // Smaller chunk sizes run slower overall, as the per-chunk overhead is high.
12 // Testing on my machine has shown that we need 10-15 chunks before style resolution is always the top sample.
13 var chunkSize = 500000; // 6.09mb / 500k = approx 13 chunks (thus 13 forced layouts/style resolves).
14 var chunkCount = Math.ceil(spec.length / chunkSize);
15 for (var chunkIndex = 0; chunkIndex < chunkCount; chunkIndex++) {
16 var chunk = spec.substring(chunkIndex * chunkSize, chunkSize);
20 PerfTestRunner.logInfo("Testing " + spec.length + " byte document in " + chunkCount + " " + chunkSize + " byte chunks.");
22 function loadChunkedSpecIntoIframe(iframe) {
23 // Note: We've inlined the stylesheets in html5.html. Before we did that, it seemed to be
24 // random as to whether style resolution would show up at all in the samples.
25 // Talking with Hyatt and jamesr we believe this may be the ignorePendingStylesheets
26 // logic which is triggered off of a timer which is fired after the load completes.
27 // By inlining the stylesheets we're avoiding this race condition.
28 iframe.sandbox = ''; // Prevent external loads which could cause write() to return before completing the parse.
29 iframe.style.width = "600px"; // Have a reasonable size so we're not line-breaking on every character.
30 iframe.style.height = "800px";
31 iframe.contentDocument.open();
33 for (var chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
34 iframe.contentDocument.write(chunks[chunkIndex]);
35 // Note that we won't cause a style resolve until we've encountered the <body> element.
36 // Thus the number of chunks counted above is not exactly equal to the number of style resolves.
37 if (iframe.contentDocument.body)
38 iframe.contentDocument.body.clientHeight; // Force a full layout/style-resolve.
41 iframe.contentDocument.close();
44 // Running from the onload callback just makes the UI nicer as it shows the logs before starting the test.
45 window.onload = function() {
46 // Depending on the chosen chunk size, iterations can take over 60s to run on a fast machine, so we only run 2.
47 PerfTestRunner.run(function() {
48 var iframe = document.createElement("iframe");
49 document.body.appendChild(iframe);
50 loadChunkedSpecIntoIframe(iframe);
51 document.body.removeChild(iframe);
52 }, 1, 2); // We only loop once for each run, again because this test is so slow.