Changeset 190902 in webkit


Ignore:
Timestamp:
Oct 12, 2015 4:22:23 PM (9 years ago)
Author:
jonlee@apple.com
Message:

Refactor test suites to a separate class.
https://bugs.webkit.org/show_bug.cgi?id=150053
<rdar://problem/23078645>

Reviewed by Dean Jackson.

Create a Suite class to refactor out prepare() and run().
Generate the checkboxes representing the suites using Suites
instead of maintaining a separate list. Also, save the
selections out to localStorage.

  • Animometer/runner/animometer.html: Remove the explicitly listed

suites. These will be generated from Suites instead.

  • Animometer/runner/resources/animometer.js:

(populateSettings): Iterate through Suites, and create the
label and checkbox. Attach the Suite object to the checkbox so
when the benchmark is started, we get direct access. Initialize
the checkmark based on its value in localStorage. Set this to
run when DOMContentLoaded is dispatched.
(startBenchmark): Grab all of the checkboxes, inspect their
values, add it to enabledSuites if selected. Remember whether
the suite was enabled in localStorage, so that it's easy to do
repeated runs.

  • Animometer/runner/resources/tests.js:

(Suite): Create a new Suite class. Refactor out prepare() and
run(), since all of them have the same implementation. Populate
Suites with Suite instances instead of generic objects.

Location:
trunk/PerformanceTests
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/PerformanceTests/Animometer/runner/animometer.html

    r190575 r190902  
    2020            </p>
    2121            <div class="options">
    22                 <div class="column">
    23                     <label><input id="html-suite" type="checkbox" checked> HTML elements suite</label><br>
    24                     <label><input id="canvas-suite" type="checkbox" checked> Canvas drawings suite</label><br>
    25                     <label><input id="svg-suite" type="checkbox" checked> SVG elements suite</label><br>
    26                     <label><input id="examples-suite" type="checkbox"> Examples suite</label><br>
    27                     <label><input id="template-suite" type="checkbox"> Template suite</label>
     22                <div id="suites" class="column">
    2823                </div>
    2924                <div>
  • trunk/PerformanceTests/Animometer/runner/resources/animometer.js

    r190575 r190902  
    6060function startBenchmark()
    6161{
    62     var checkboxes = [
    63         document.getElementById("html-suite"),
    64         document.getElementById("canvas-suite"),
    65         document.getElementById("svg-suite"),
    66         document.getElementById("examples-suite"),
    67         document.getElementById("template-suite"),
    68     ];
     62    var enabledSuites = [];
     63    var checkboxes = document.querySelectorAll("#suites input");
     64    for (var i = 0; i < checkboxes.length; ++i) {
     65        var checkbox = checkboxes[i];
     66        if (checkbox.checked) {
     67            enabledSuites.push(checkbox.suite);
     68        }
     69        localStorage.setItem(checkbox.suite.name, +checkbox.checked);
     70    }
     71
    6972    var enabledSuites = Suites.filter(function (suite, index) { return !suite.disabled && checkboxes[index].checked; });
    7073    var testsCount = enabledSuites.reduce(function (testsCount, suite) { return testsCount + suite.tests.length; }, 0);
     
    111114    showSection("graph", true);   
    112115}
     116
     117function populateSettings() {
     118    var suitesDiv = document.getElementById("suites");
     119    Suites.forEach(function(suite) {
     120        var suiteDiv = document.createDocumentFragment();
     121
     122        var label = document.createElement("label");
     123        var checkbox = document.createElement("input");
     124        checkbox.setAttribute("type", "checkbox");
     125        checkbox.suite = suite;
     126        if (+localStorage.getItem(suite.name)) {
     127            checkbox.checked = true;
     128        }
     129        label.appendChild(checkbox);
     130        label.appendChild(document.createTextNode(" " + suite.name));
     131
     132        suiteDiv.appendChild(label);
     133        suiteDiv.appendChild(document.createElement("br"));
     134        suitesDiv.appendChild(suiteDiv);
     135    });
     136}
     137document.addEventListener("DOMContentLoaded", populateSettings);
  • trunk/PerformanceTests/Animometer/runner/resources/tests.js

    r190575 r190902  
    3939];
    4040
     41var Suite = function(name, tests) {
     42    this.name = name;
     43    this.titles = Titles;
     44    this.tests = tests;
     45};
     46Suite.prototype.prepare = function(runner, contentWindow, contentDocument)
     47{
     48    return runner.waitForElement("#stage").then(function (element) {
     49        return element;
     50    });
     51};
     52Suite.prototype.run = function(contentWindow, test, options, recordTable, progressBar)
     53{
     54    return contentWindow.runBenchmark(this, test, options, recordTable, progressBar);
     55};
     56
     57
    4158var Suites = [];
    4259
    43 Suites.push({
    44     name: "HTML Bouncing Particles",
    45     prepare: function(runner, contentWindow, contentDocument)
    46     {
    47         return runner.waitForElement("#stage").then(function (element) {
    48             return element;
    49         });
    50     },
    51    
    52     run: function(contentWindow, test, options, recordTable, progressBar)
    53     {
    54         return contentWindow.runBenchmark(this, test, options, recordTable, progressBar);
    55     },
    56 
    57     titles: Titles,
    58     tests: [
     60Suites.push(new Suite("HTML suite",
     61    [
    5962        {
    6063            url: "../tests/bouncing-particles/bouncing-css-shapes.html?gain=1&addLimit=100&removeLimit=5&particleWidth=12&particleHeight=12&shape=circle",
     
    8285        },
    8386    ]
    84 });
     87));
    8588
    86 Suites.push({
    87     name: "Canvas Bouncing Particles",
    88     prepare: function(runner, contentWindow, contentDocument)
    89     {
    90         return runner.waitForElement("#stage").then(function (element) {
    91             return element;
    92         });
    93     }, 
    94    
    95     run: function(contentWindow, test, options, recordTable, progressBar)
    96     {
    97         return contentWindow.runBenchmark(this, test, options, recordTable, progressBar);
    98     },
    99    
    100     titles: Titles,
    101     tests: [
     89Suites.push(new Suite("Canvas suite",
     90    [
    10291        {
    10392            url: "../tests/bouncing-particles/bouncing-canvas-shapes.html?gain=4&addLimit=100&removeLimit=1000&particleWidth=12&particleHeight=12&shape=circle",
     
    121110        },
    122111    ]
    123 });
     112));
    124113
    125 Suites.push({
    126     name: "SVG Bouncing Particles",
    127     prepare: function(runner, contentWindow, contentDocument)
    128     {
    129         return runner.waitForElement("#stage").then(function (element) {
    130             return element;
    131         });
    132     },
    133    
    134     run: function(contentWindow, test, options, recordTable, progressBar)
    135     {
    136         return contentWindow.runBenchmark(this, test, options, recordTable, progressBar);
    137     },
    138    
    139     titles: Titles,
    140     tests: [
     114Suites.push(new Suite("SVG suite",
     115    [
    141116        {
    142117            url: "../tests/bouncing-particles/bouncing-svg-shapes.html?gain=6&addLimit=100&removeLimit=1000&particleWidth=12&particleHeight=12&shape=circle",
     
    160135        },
    161136    ]
    162 });
     137));
    163138
    164 Suites.push({
    165     name: "More complex examples",
    166     prepare: function(runner, contentWindow, contentDocument)
    167     {
    168         return runner.waitForElement("#stage").then(function (element) {
    169             return element;
    170         });
    171     },
    172    
    173     run: function(contentWindow, test, options, recordTable, progressBar)
    174     {
    175         return contentWindow.runBenchmark(this, test, options, recordTable, progressBar);
    176     },
    177    
    178     titles: Titles,
    179     tests: [
     139Suites.push(new Suite("Complex examples",
     140    [
    180141        {
    181142            url: "../tests/examples/canvas-electrons.html?gain=1&addLimit=100&removeLimit=10",
     
    187148        },
    188149    ]
    189 });
     150));
    190151
    191 Suites.push({
    192     name: "Stage Templates (Can be used for new tests)",
    193     prepare: function(runner, contentWindow, contentDocument)
    194     {
    195         return runner.waitForElement("#stage").then(function (element) {
    196             return element;
    197         });
    198     },
    199    
    200     run: function(contentWindow, test, options, recordTable, progressBar)
    201     {
    202         return contentWindow.runBenchmark(this, test, options, recordTable, progressBar);
    203     },
    204    
    205     titles: Titles,
    206     tests: [
     152Suites.push(new Suite("Test Templates",
     153    [
    207154        {
    208155            url: "../tests/template/template-css.html?gain=1&addLimit=100&removeLimit=5",
     
    218165        },
    219166    ]
    220 });
     167));
    221168
    222169function suiteFromName(name)
  • trunk/PerformanceTests/ChangeLog

    r190901 r190902  
     12015-10-12  Jon Lee  <jonlee@apple.com>
     2
     3        Refactor test suites to a separate class.
     4        https://bugs.webkit.org/show_bug.cgi?id=150053
     5        <rdar://problem/23078645>
     6
     7        Reviewed by Dean Jackson.
     8
     9        Create a Suite class to refactor out prepare() and run().
     10        Generate the checkboxes representing the suites using Suites
     11        instead of maintaining a separate list. Also, save the
     12        selections out to localStorage.
     13
     14        * Animometer/runner/animometer.html: Remove the explicitly listed
     15        suites. These will be generated from Suites instead.
     16        * Animometer/runner/resources/animometer.js:
     17        (populateSettings): Iterate through Suites, and create the
     18        label and checkbox. Attach the Suite object to the checkbox so
     19        when the benchmark is started, we get direct access. Initialize
     20        the checkmark based on its value in localStorage. Set this to
     21        run when DOMContentLoaded is dispatched.
     22        (startBenchmark): Grab all of the checkboxes, inspect their
     23        values, add it to enabledSuites if selected. Remember whether
     24        the suite was enabled in localStorage, so that it's easy to do
     25        repeated runs.
     26        * Animometer/runner/resources/tests.js:
     27        (Suite): Create a new Suite class. Refactor out prepare() and
     28        run(), since all of them have the same implementation. Populate
     29        Suites with Suite instances instead of generic objects.
     30
     312015-10-12  Jon Lee  <jonlee@apple.com>
     32
     33        Update graph styles for legibility.
     34        https://bugs.webkit.org/show_bug.cgi?id=150052
     35        <rdar://problem/23078503>
     36
     37        Reviewed by Dean Jackson.
     38
     39        * Animometer/runner/resources/animometer.css: Update colors and
     40        stroke thicknesses to make the graphs easier to read.
     41        (.smaple-time): Correct to .sample-time
     42        * Animometer/runner/resources/graph.js:
     43        (graph): Ditto.
     44
    1452015-10-12  Jon Lee  <jonlee@apple.com>
    246
Note: See TracChangeset for help on using the changeset viewer.