1 window.benchmarkRunnerClient = {
6 options: { testInterval: 30000, frameRate: 50, estimatedFrameRate: true, fixTestComplexity : false },
8 _iterationsSamplers: [],
11 willAddTestFrame: function (frame)
13 var main = document.querySelector("main");
14 var style = getComputedStyle(main);
15 frame.style.left = main.offsetLeft + parseInt(style.borderLeftWidth) + parseInt(style.paddingLeft) + "px";
16 frame.style.top = main.offsetTop + parseInt(style.borderTopWidth) + parseInt(style.paddingTop) + "px";
19 didRunTest: function ()
21 this.progressBar.incRange();
24 willStartFirstIteration: function ()
26 this._iterationsSamplers = [];
27 this._resultsTable = new RecordTable(document.querySelectorAll(".results-table")[0]);
29 this.progressBar = new ProgressBar(document.getElementById("progress-completed"), this.testsCount);
30 this.recordTable = new RecordTable(document.querySelectorAll(".record-table")[0]);
33 didRunSuites: function (suitesSamplers)
35 this._iterationsSamplers.push(suitesSamplers);
38 didFinishLastIteration: function ()
40 this.score = this._resultsTable.showIterations(this._iterationsSamplers, "");
45 function showSection(sectionIdentifier, pushState)
47 var currentSectionElement = document.querySelector("section.selected");
48 console.assert(currentSectionElement);
50 var newSectionElement = document.getElementById(sectionIdentifier);
51 console.assert(newSectionElement);
53 currentSectionElement.classList.remove("selected");
54 newSectionElement.classList.add("selected");
57 history.pushState({section: sectionIdentifier}, document.title);
60 function startBenchmark()
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);
69 localStorage.setItem(checkbox.suite.name, +checkbox.checked);
70 localStorage.setItem("test-interval", document.getElementById("test-interval").value);
73 var enabledSuites = Suites.filter(function (suite, index) { return !suite.disabled && checkboxes[index].checked; });
74 var testsCount = enabledSuites.reduce(function (testsCount, suite) { return testsCount + suite.tests.length; }, 0);
75 benchmarkRunnerClient.testsCount = benchmarkRunnerClient.iterationCount * testsCount;
76 benchmarkRunnerClient.options["testInterval"] = parseInt(document.getElementById("test-interval").value) * 1000;
77 benchmarkRunnerClient.options["frameRate"] = parseInt(document.getElementById("frame-rate").value);
78 benchmarkRunnerClient.options["estimatedFrameRate"] = document.getElementById("estimated-frame-rate").checked;
79 benchmarkRunnerClient.options["fixTestComplexity"] = document.getElementById("fix-test-complexity").checked;
80 benchmarkRunnerClient.options["showRunningResults"] = document.getElementById("show-running-results").checked;
82 if (!benchmarkRunnerClient.options["showRunningResults"])
83 document.getElementById("record").style.display = "none";
85 var runner = new BenchmarkRunner(enabledSuites, benchmarkRunnerClient);
86 runner.runMultipleIterations(benchmarkRunnerClient.iterationCount);
91 showSection("running");
95 function showResults(score)
97 var element = document.querySelector("#results > h1");
98 element.textContent = "Results:"
100 var score = benchmarkRunnerClient.score.toFixed(2);
101 element.textContent += " [Score = " + score + "]";
103 showSection("results", true);
106 function showGraph(testName, axes, samples, samplingTimeOffset)
108 var element = document.querySelector("#graph > h1");
109 element.textContent = "Graph:"
112 element.textContent += " [test = " + testName + "]";
114 graph("#graphContainer", new Point(700, 400), new Insets(20, 50, 20, 50), axes, samples, samplingTimeOffset);
115 showSection("graph", true);
118 function populateSettings() {
119 var suitesDiv = document.getElementById("suites");
120 Suites.forEach(function(suite) {
121 var suiteDiv = document.createDocumentFragment();
123 var label = document.createElement("label");
124 var checkbox = document.createElement("input");
125 checkbox.setAttribute("type", "checkbox");
126 checkbox.suite = suite;
127 if (+localStorage.getItem(suite.name)) {
128 checkbox.checked = true;
130 label.appendChild(checkbox);
131 label.appendChild(document.createTextNode(" " + suite.name));
133 suiteDiv.appendChild(label);
134 suiteDiv.appendChild(document.createElement("br"));
135 suitesDiv.appendChild(suiteDiv);
138 var interval = localStorage.getItem("test-interval");
140 document.getElementById("test-interval").value = interval;
143 document.addEventListener("DOMContentLoaded", populateSettings);