Changeset 132273 in webkit


Ignore:
Timestamp:
Oct 23, 2012 3:03:55 PM (12 years ago)
Author:
zoltan@webkit.org
Message:

Add measurePageLoadTime function to PerfTestRunner
https://bugs.webkit.org/show_bug.cgi?id=100029

Reviewed by Ryosuke Niwa.

Adopt chunk based loading logic from html5-full-render.html into measurePageLoadTime function,
this is needed to measure the performance and the memory consumption of the PageLoadTests as
we do it for all other performancetests.

  • Parser/html5-full-render.html: Move the behavior to runner.js.
  • resources/runner.js:

(.): Add measurePageLoadTime function.

Location:
trunk/PerformanceTests
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/PerformanceTests/ChangeLog

    r132114 r132273  
     12012-10-23  Zoltan Horvath  <zoltan@webkit.org>
     2
     3        Add measurePageLoadTime function to PerfTestRunner
     4        https://bugs.webkit.org/show_bug.cgi?id=100029
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Adopt chunk based loading logic from html5-full-render.html into measurePageLoadTime function,
     9        this is needed to measure the performance and the memory consumption of the PageLoadTests as
     10        we do it for all other performancetests.
     11
     12        * Parser/html5-full-render.html: Move the behavior to runner.js.
     13        * resources/runner.js:
     14        (.): Add measurePageLoadTime function.
     15
    1162012-10-22  Adam Barth  <abarth@webkit.org>
    217
  • trunk/PerformanceTests/Parser/html5-full-render.html

    r131689 r132273  
    33<script src="../resources/runner.js"></script>
    44<script>
    5 var spec = PerfTestRunner.loadFile("resources/html5.html");
    6 
    7 var chunks = [];
    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.substr(chunkIndex * chunkSize, chunkSize);
    17     chunks.push(chunk);
    18 }
    19 
    20 PerfTestRunner.logInfo("Testing " + spec.length + " byte document in " + chunkCount + " " + chunkSize + " byte chunks.");
    21 
    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();
    32 
    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.
    39     }
    40 
    41     iframe.contentDocument.close();
    42 }
    43 
    445// Running from the onload callback just makes the UI nicer as it shows the logs before starting the test.
    456window.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.measureTime({run: function() {
    48         var iframe = document.createElement("iframe");
    49         document.body.appendChild(iframe);
    50         loadChunkedSpecIntoIframe(iframe);
    51         document.body.removeChild(iframe);
    52     }, runCount: 5});
     7    PerfTestRunner.measurePageLoadTime({path: "resources/html5.html",
     8    chunkSize: 500000, // 6.09mb / 500k = approx 13 chunks (thus 13 forced layouts/style resolves).
     9    runCount: 5 }); // Depending on the chosen chunk size, iterations can take over 60s to run on a fast machine, so we only run 5.
    5310}
    5411
  • trunk/PerformanceTests/resources/runner.js

    r131651 r132273  
    304304    }
    305305
     306
     307    PerfTestRunner.measurePageLoadTime = function(test) {
     308        test.run = function() {
     309            var chunks = [];
     310            // The smaller the chunks the more style resolves we do.
     311            // Smaller chunk sizes will show more samples in style resolution.
     312            // Larger chunk sizes will show more samples in line layout.
     313            // Smaller chunk sizes run slower overall, as the per-chunk overhead is high.
     314            var chunkCount = Math.ceil(this.file.length / this.chunkSize);
     315            for (var chunkIndex = 0; chunkIndex < chunkCount; chunkIndex++) {
     316                var chunk = this.file.substr(chunkIndex * this.chunkSize, this.chunkSize);
     317                chunks.push(chunk);
     318            }
     319
     320            PerfTestRunner.logInfo("Testing " + this.file.length + " byte document in " + chunkCount + " " + this.chunkSize + " byte chunks.");
     321
     322            var iframe = document.createElement("iframe");
     323            document.body.appendChild(iframe);
     324
     325            iframe.sandbox = '';  // Prevent external loads which could cause write() to return before completing the parse.
     326            iframe.style.width = "600px"; // Have a reasonable size so we're not line-breaking on every character.
     327            iframe.style.height = "800px";
     328            iframe.contentDocument.open();
     329
     330            for (var chunkIndex = 0; chunkIndex < chunks.length; chunkIndex++) {
     331                iframe.contentDocument.write(chunks[chunkIndex]);
     332                // Note that we won't cause a style resolve until we've encountered the <body> element.
     333                // Thus the number of chunks counted above is not exactly equal to the number of style resolves.
     334                if (iframe.contentDocument.body)
     335                    iframe.contentDocument.body.clientHeight; // Force a full layout/style-resolve.
     336                else if (iframe.documentElement.localName == 'html')
     337                    iframe.contentDocument.documentElement.offsetWidth; // Force the painting.
     338            }
     339
     340            iframe.contentDocument.close();
     341            document.body.removeChild(iframe);
     342        };
     343
     344        this.file = PerfTestRunner.loadFile(test.path);
     345        if (!test.chunkSize)
     346            this.chunkSize = 50000;
     347
     348        PerfTestRunner.measureTime(test);
     349    }
     350
    306351    window.PerfTestRunner = PerfTestRunner;
    307352})();
Note: See TracChangeset for help on using the changeset viewer.