Add an option to make the graphics benchmark runs a specific test
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Oct 2015 23:11:37 +0000 (23:11 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 28 Oct 2015 23:11:37 +0000 (23:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150528
rdar://problem/23246614

Reviewed by Zalan Bujtas.

Add a checkbox that lets the user list all of the available tests, and select
the ones to run repeatedly. The test checkboxes will update the state of the suite
checkbox. The selected tests are stored in localStorage to make it easy to do
repeated runs.

* Animometer/runner/animometer.html: Add a checkbox to show individual tests.
Update other markup.
* Animometer/runner/resources/animometer.css: Make the settings area a little wider
to accommodate the longer names of the tests
* Animometer/runner/resources/animometer.js:
(startBenchmark): Change the way that the suites are fed into the benchmark
runner. Go through each of the suites and their tests, and create a new Suite
with just the enabled tests. While enumerating store the enabled tests into
localStorage.
(initialize): Initialization routine (taking over populateSettings). When the
checkbox for showing tests is toggled, add or remove a class on #suites to show
the individual tests.
(updateSuiteSelection): Called whenever the user toggles the checkbox for a suite.
Either select all or none of the tests.
(updateTestSelection): Called whenever the user toggles the checkbox for a test.
(updateSuiteCheckbox): Update the state of the test's suite's checkbox to
indeterminate if there is at least one enabled test, unchecked if none are selected,
and checked if all are selected.
(localStorageNameForTest): Helper function to get the name of the test to use as
a key to localStorage.
(populateSettings): Add the tests for each suite into an inner list.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@191701 268f45cc-cd09-0410-ab3c-d52691b4dbfc

PerformanceTests/Animometer/runner/animometer.html
PerformanceTests/Animometer/runner/resources/animometer.css
PerformanceTests/Animometer/runner/resources/animometer.js
PerformanceTests/ChangeLog

index 1c3e31a..2a93ba6 100644 (file)
             </p>
             <div class="options">
                 <div id="suites" class="column">
+                <p>
+                    <label><input type="checkbox" id="toggleTests"> Show individual tests</label>
+                </p>
+                Suites:<br>
                 </div>
                 <div>
                     <label>Test interval: <input id="test-interval" type="number" value="30"> seconds</label><br>
                     <label>Frame rate: <input id="frame-rate" type="number" value="50"> fps</label><br>
                     <label><input id="estimated-frame-rate" type="checkbox" checked> Estimated Frame Rate</label><br>
-                    <label><input id="fix-test-complexity" type="checkbox"> Fix test complexity after warmup</label>
+                    <label><input id="fix-test-complexity" type="checkbox"> Fix test complexity after warmup</label><br>
                     <label><input id="show-running-results" type="checkbox"> Show running results</label>
                 </div>
             </div>
index af79626..4b3e6a0 100644 (file)
@@ -131,15 +131,36 @@ section#json > textarea {
 .options {
     margin:0 auto;    
     margin-top: 30px;
-    width: 500px;
+    width: 600px;
     align: center;
 }
 
+.options p {
+    margin-top: 0;
+}
+
+#suites ul {
+    list-style-type: none;
+    margin: 0;
+    padding: 0;
+}
+
+#suites ul ul {
+    padding-left: 1.5em;
+    display: none;
+}
+
+#suites ul ul input, #suites ul ul label {
+    font-size: .8em;
+}
+
+#suites.showTests ul ul {
+    display: block;
+}
+
 .column {
-    width: 45%;
+    width: 55%;
     float:left;
-    height: 120px;
-    padding:5px;
 }
 
 input[type="number"] {
index aaea4f1..0b1b7e8 100644 (file)
@@ -70,17 +70,32 @@ function showSection(sectionIdentifier, pushState)
 function startBenchmark()
 {
     var enabledSuites = [];
-    var checkboxes = document.querySelectorAll("#suites input");
-    for (var i = 0; i < checkboxes.length; ++i) {
-        var checkbox = checkboxes[i];
-        if (checkbox.checked) {
-            enabledSuites.push(checkbox.suite);
+
+    localStorage.clear();
+    var suiteItems = document.querySelectorAll("#suites > ul > li");
+    for (var i = 0; i < suiteItems.length; ++i) {
+        var suiteItem = suiteItems[i];
+        var suiteCheckbox = suiteItem.querySelector("input");
+
+        if (!suiteCheckbox.checked)
+            continue;
+
+        var enabledTests = [];
+        var testCheckboxes = suiteItem.querySelector("ul").querySelectorAll("input");
+        for (var j = 0; j < testCheckboxes.length; ++j) {
+            var testCheckbox = testCheckboxes[j];
+            if (!testCheckbox.checked)
+                continue;
+
+            enabledTests.push(testCheckbox.test);
+            localStorage.setItem(localStorageNameForTest(suiteCheckbox.suite, testCheckbox.test), +testCheckbox.checked);
         }
-        localStorage.setItem(checkbox.suite.name, +checkbox.checked);
-        localStorage.setItem("test-interval", document.getElementById("test-interval").value);
+
+        enabledSuites.push(new Suite(suiteCheckbox.suite.name, enabledTests));
     }
 
-    var enabledSuites = Suites.filter(function (suite, index) { return !suite.disabled && checkboxes[index].checked; });
+    localStorage.setItem("test-interval", document.getElementById("test-interval").value);
+
     var testsCount = enabledSuites.reduce(function (testsCount, suite) { return testsCount + suite.tests.length; }, 0);
     benchmarkRunnerClient.testsCount = benchmarkRunnerClient.iterationCount * testsCount;
     benchmarkRunnerClient.options["testInterval"] = parseInt(document.getElementById("test-interval").value) * 1000;
@@ -154,24 +169,90 @@ function showTestJSON(testName, testResults)
     showSection("test-json", true);    
 }
 
+function initialize() {
+    populateSettings();
+
+    var toggleTestsCheckbox = document.getElementById("toggleTests");
+    toggleTestsCheckbox.onchange = function(event) {
+        if (event.target.checked)
+            document.getElementById("suites").classList.add("showTests");
+        else
+            document.getElementById("suites").classList.remove("showTests");
+    };
+}
+
+function updateSuiteSelection(event) {
+    var selected = event.target.checked;
+    var testCheckboxes = event.target.parentNode.parentNode.querySelector("ul").querySelectorAll("input");
+    for (var i = 0; i < testCheckboxes.length; ++i) {
+        testCheckboxes[i].checked = selected;
+    }
+}
+
+function updateTestSelection(event) {
+    var testsList = event.target.parentNode.parentNode.parentNode;
+    var suiteCheckbox = testsList.parentNode.querySelector("label > input");
+
+    updateSuiteCheckbox(testsList, suiteCheckbox);
+}
+
+function updateSuiteCheckbox(testsList, suiteCheckbox) {
+    var numberEnabledTests = 0;
+    var testCheckboxes = testsList.querySelectorAll("input");
+    var totalCheckboxes = testCheckboxes.length;
+    for (var i = 0; i < totalCheckboxes; ++i) {
+        if (testCheckboxes[i].checked)
+            ++numberEnabledTests;
+    }
+    suiteCheckbox.checked = numberEnabledTests > 0;
+    suiteCheckbox.indeterminate = numberEnabledTests > 0 && numberEnabledTests < totalCheckboxes;
+}
+
+function localStorageNameForTest(suite, test) {
+    return suite.name + "/" + test.name;
+}
+
 function populateSettings() {
     var suitesDiv = document.getElementById("suites");
+
+    var suitesList = document.createElement("ul");
+    suitesDiv.appendChild(suitesList);
+
     Suites.forEach(function(suite) {
-        var suiteDiv = document.createDocumentFragment();
-
-        var label = document.createElement("label");
-        var checkbox = document.createElement("input");
-        checkbox.setAttribute("type", "checkbox");
-        checkbox.suite = suite;
-        if (+localStorage.getItem(suite.name)) {
-            checkbox.checked = true;
-        }
-        label.appendChild(checkbox);
-        label.appendChild(document.createTextNode(" " + suite.name));
+        var suiteItem = document.createElement("li");
+        suitesList.appendChild(suiteItem);
+
+        var suiteLabel = document.createElement("label");
+        suiteItem.appendChild(suiteLabel);
+
+        var suiteCheckbox = document.createElement("input");
+        suiteCheckbox.setAttribute("type", "checkbox");
+        suiteCheckbox.suite = suite;
+        suiteCheckbox.onchange = updateSuiteSelection;
+        suiteLabel.appendChild(suiteCheckbox);
+        suiteLabel.appendChild(document.createTextNode(" " + suite.name));
+
+        var testsList = document.createElement("ul");
+        suiteItem.appendChild(testsList);
+
+        suite.tests.forEach(function(test) {
+            var testItem = document.createElement("li");
+            testsList.appendChild(testItem);
+
+            var testLabel = document.createElement("label");
+            testItem.appendChild(testLabel);
+
+            var testCheckbox = document.createElement("input");
+            testCheckbox.setAttribute("type", "checkbox");
+            testCheckbox.test = test;
+            testCheckbox.onchange = updateTestSelection;
+            if (+localStorage.getItem(localStorageNameForTest(suite, test)))
+                testCheckbox.checked = true;
+            testLabel.appendChild(testCheckbox);
+            testLabel.appendChild(document.createTextNode(" " + test.name));
+        });
 
-        suiteDiv.appendChild(label);
-        suiteDiv.appendChild(document.createElement("br"));
-        suitesDiv.appendChild(suiteDiv);
+        updateSuiteCheckbox(testsList, suiteCheckbox);
     });
 
     var interval = localStorage.getItem("test-interval");
@@ -179,4 +260,4 @@ function populateSettings() {
         document.getElementById("test-interval").value = interval;
     }
 }
-document.addEventListener("DOMContentLoaded", populateSettings);
\ No newline at end of file
+document.addEventListener("DOMContentLoaded", initialize);
index 3e0a7f0..28ba618 100644 (file)
@@ -1,3 +1,38 @@
+2015-10-27  Jon Lee  <jonlee@apple.com>
+
+        Add an option to make the graphics benchmark runs a specific test
+        https://bugs.webkit.org/show_bug.cgi?id=150528
+        rdar://problem/23246614
+
+        Reviewed by Zalan Bujtas.
+
+        Add a checkbox that lets the user list all of the available tests, and select
+        the ones to run repeatedly. The test checkboxes will update the state of the suite
+        checkbox. The selected tests are stored in localStorage to make it easy to do
+        repeated runs.
+
+        * Animometer/runner/animometer.html: Add a checkbox to show individual tests.
+        Update other markup.
+        * Animometer/runner/resources/animometer.css: Make the settings area a little wider
+        to accommodate the longer names of the tests
+        * Animometer/runner/resources/animometer.js:
+        (startBenchmark): Change the way that the suites are fed into the benchmark
+        runner. Go through each of the suites and their tests, and create a new Suite
+        with just the enabled tests. While enumerating store the enabled tests into
+        localStorage.
+        (initialize): Initialization routine (taking over populateSettings). When the
+        checkbox for showing tests is toggled, add or remove a class on #suites to show
+        the individual tests.
+        (updateSuiteSelection): Called whenever the user toggles the checkbox for a suite.
+        Either select all or none of the tests.
+        (updateTestSelection): Called whenever the user toggles the checkbox for a test.
+        (updateSuiteCheckbox): Update the state of the test's suite's checkbox to
+        indeterminate if there is at least one enabled test, unchecked if none are selected,
+        and checked if all are selected.
+        (localStorageNameForTest): Helper function to get the name of the test to use as
+        a key to localStorage.
+        (populateSettings): Add the tests for each suite into an inner list.
+
 2015-10-26  Said Abou-Hallawa  <sabouhallawa@apple.com>
 
         Add an option to output the results of the graphics benchmark in JSON format