https://bugs.webkit.org/show_bug.cgi?id=97743
Reviewed by Kentaro Hara.
Rename PerfTestRunner.run to PerfTestRunner.measureTime and make it take an object instead of
5 arguments. Also get rid of PerfTestRunner._loopsPerRun since it's no longer used (it's always 1).
* CSS/StyleSheetInsert.html:
* DOM/resources/dom-perf.js:
* Layout/floats_100_100.html:
* Layout/floats_100_100_nested.html:
* Layout/floats_20_100.html:
* Layout/floats_20_100_nested.html:
* Layout/floats_2_100.html:
* Layout/floats_2_100_nested.html:
* Layout/floats_50_100.html:
* Layout/floats_50_100_nested.html:
* Parser/html-parser.html:
* Parser/html5-full-render.html:
* SVG/SvgCubics.html:
* SVG/SvgHitTesting.html:
* resources/runner.js:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@129824
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
return testDoc;
}
-PerfTestRunner.run(function() {
+PerfTestRunner.measureTime({run:function() {
var testDoc = setup();
var start = PerfTestRunner.now();
for (var i = 0; i < 50; i++) {
testDoc.body.insertBefore(styleElem, testDoc.body.firstChild);
}
return PerfTestRunner.now() - start;
-}, 1);
+}});
</script>
</html>
2012-09-27 Ryosuke Niwa <rniwa@webkit.org>
+ PerfTestRunner.run should take an object
+ https://bugs.webkit.org/show_bug.cgi?id=97743
+
+ Reviewed by Kentaro Hara.
+
+ Rename PerfTestRunner.run to PerfTestRunner.measureTime and make it take an object instead of
+ 5 arguments. Also get rid of PerfTestRunner._loopsPerRun since it's no longer used (it's always 1).
+
+ * CSS/StyleSheetInsert.html:
+ * DOM/resources/dom-perf.js:
+ * Layout/floats_100_100.html:
+ * Layout/floats_100_100_nested.html:
+ * Layout/floats_20_100.html:
+ * Layout/floats_20_100_nested.html:
+ * Layout/floats_2_100.html:
+ * Layout/floats_2_100_nested.html:
+ * Layout/floats_50_100.html:
+ * Layout/floats_50_100_nested.html:
+ * Parser/html-parser.html:
+ * Parser/html5-full-render.html:
+ * SVG/SvgCubics.html:
+ * SVG/SvgHitTesting.html:
+ * resources/runner.js:
+
+2012-09-27 Ryosuke Niwa <rniwa@webkit.org>
+
PerformanceTests/CSS/StyleSheetInsert.html has a time-dependent non-Gaussian distribution
https://bugs.webkit.org/show_bug.cgi?id=97741
};
function runBenchmarkSuite(suite, runCount) {
- PerfTestRunner.run(function () {
+ PerfTestRunner.measureTime({run: function () {
var container = document.getElementById('container');
var content = document.getElementById('benchmark_content');
suite.benchmarkContentHolder = container;
totalMeanTime += result.mean;
}
return totalMeanTime;
- }, 1, runCount || 20, function () {
+ },
+ runCount: runCount,
+ done: function () {
var container = document.getElementById('container');
if (container.firstChild)
container.removeChild(container.firstChild);
<body>
<pre id="log"></pre>
<script>
- PerfTestRunner.run(createFloatsLayoutTestFunction(100, 100, 0, 3), 1, 2);
+ PerfTestRunner.measureTime({run: createFloatsLayoutTestFunction(100, 100, 0, 3),
+ runCount: 2});
</script>
</body>
</html>
<body>
<pre id="log"></pre>
<script>
- PerfTestRunner.run(createFloatsLayoutTestFunction(100, 100, 100, 3), 1, 2);
+ PerfTestRunner.measureTime({run: createFloatsLayoutTestFunction(100, 100, 100, 3),
+ runCount: 2});
</script>
</body>
</html>
<body>
<pre id="log"></pre>
<script>
- PerfTestRunner.run(createFloatsLayoutTestFunction(20, 100, 0, 100), 1, 7);
+ PerfTestRunner.measureTime({run: createFloatsLayoutTestFunction(20, 100, 0, 100),
+ runCount: 7});
</script>
</body>
</html>
<body>
<pre id="log"></pre>
<script>
- PerfTestRunner.run(createFloatsLayoutTestFunction(20, 100, 100, 100), 1, 6);
+ PerfTestRunner.measureTime({run: createFloatsLayoutTestFunction(20, 100, 100, 100),
+ runCount: 6});
</script>
</body>
</html>
<body>
<pre id="log"></pre>
<script>
- PerfTestRunner.run(createFloatsLayoutTestFunction(2, 100, 0, 500), 1, 10);
+ PerfTestRunner.measureTime({run: createFloatsLayoutTestFunction(2, 100, 0, 500),
+ runCount: 10});
</script>
</body>
</html>
<body>
<pre id="log"></pre>
<script>
- PerfTestRunner.run(createFloatsLayoutTestFunction(2, 100, 100, 250), 1, 10);
+ PerfTestRunner.measureTime({run: createFloatsLayoutTestFunction(2, 100, 100, 250),
+ runCount: 10});
</script>
</body>
</html>
<body>
<pre id="log"></pre>
<script>
- PerfTestRunner.run(createFloatsLayoutTestFunction(50, 100, 0, 20), 1, 5);
+ PerfTestRunner.measureTime({run: createFloatsLayoutTestFunction(50, 100, 0, 20),
+ runCount: 5});
</script>
</body>
</html>
<body>
<pre id="log"></pre>
<script>
- PerfTestRunner.run(createFloatsLayoutTestFunction(50, 100, 100, 20), 1, 5);
+ PerfTestRunner.measureTime({run: createFloatsLayoutTestFunction(50, 100, 100, 20),
+ runCount: 5});
</script>
</body>
</html>
<script>
var spec = PerfTestRunner.loadFile("resources/html5.html");
-PerfTestRunner.run(function() {
+PerfTestRunner.measureTime({run: function() {
var iframe = document.createElement("iframe");
iframe.style.display = "none"; // Prevent creation of the rendering tree, so we only test HTML parsing.
iframe.sandbox = ''; // Prevent external script loads which could cause write() to return before completing the parse.
iframe.contentDocument.write(spec);
iframe.contentDocument.close();
document.body.removeChild(iframe);
-}, 1);
+}});
</script>
</body>
// Running from the onload callback just makes the UI nicer as it shows the logs before starting the test.
window.onload = function() {
// Depending on the chosen chunk size, iterations can take over 60s to run on a fast machine, so we only run 2.
- PerfTestRunner.run(function() {
+ PerfTestRunner.measureTime({run: function() {
var iframe = document.createElement("iframe");
document.body.appendChild(iframe);
loadChunkedSpecIntoIframe(iframe);
document.body.removeChild(iframe);
- }, 1, 2); // We only loop once for each run, again because this test is so slow.
+ }, runCount: 2});
}
</script>
<script src="../resources/runner.js"></script>
<script>
var t = 0;
- PerfTestRunner.run(function() {
+ PerfTestRunner.measureTime({run: function() {
// transform a tiger so it spins in a circle
var rad = 0.05 * t;
var tiger1 = document.getElementById('tiger1');
document.getElementById('svg').offsetTop;
t++;
- }, 1, 20, function() {
+ }, done:function() {
var wrapper = document.getElementById('wrapper');
if (wrapper)
wrapper.parentNode.removeChild(wrapper);
- });
+ }});
</script>
</body>
</html>
</div>
<script src="../resources/runner.js"></script>
<script>
- PerfTestRunner.run(function() {
+ PerfTestRunner.measureTime({run: function() {
for (var i = 0; i < 6000; i++) {
var x = 600 * Math.random();
var y = 400 * Math.random();
var el = document.elementFromPoint(x, y);
}
- }, 1, 10, function() {
+ }, done:function() {
var wrapper = document.getElementById('wrapper');
if (wrapper)
wrapper.parentNode.removeChild(wrapper);
- });
+ }, runCount: 10});
</script>
</body>
</html>
PerfTestRunner._runner = function () {
var start = this.now();
- var totalTime = 0;
+ var returnValue = this._runFunction.call(window);
+ var end = this.now();
- for (var i = 0; i < this._loopsPerRun; ++i) {
- var returnValue = this._runFunction.call(window);
- if (returnValue - 0 === returnValue) {
- if (returnValue <= 0)
- this.log("runFunction returned a non-positive value: " + returnValue);
- totalTime += returnValue;
- }
- }
-
- // Assume totalTime can never be zero when _runFunction returns a number.
- var time = totalTime ? totalTime : this.now() - start;
+ if (returnValue - 0 === returnValue) {
+ if (returnValue <= 0)
+ this.log("runFunction returned a non-positive value: " + returnValue);
+ time = returnValue;
+ } else
+ time = end - start;
this.ignoreWarmUpAndLog(time);
this._runLoop();
this._runLoop();
}
-PerfTestRunner.run = function (runFunction, loopsPerRun, runCount, doneFunction, description) {
- this._runFunction = runFunction;
- this._loopsPerRun = loopsPerRun || 10;
- this._runCount = runCount || 20;
- this._doneFunction = doneFunction || function () {};
- this._description = description || "";
+PerfTestRunner.measureTime = function (test) {
+ this._runFunction = test.run;
+ this._doneFunction = test.done || function () {};
+ this._description = test.description || "";
+ this._runCount = test.runCount || 20;
+ this._callsPerIteration = 1;
this.unit = 'ms';
+
+ this._test = test;
this.initAndStartLoop();
}
PerfTestRunner.runPerSecond = function (test) {
- this._doneFunction = function () { if (test.done) test.done(); };
+ this._doneFunction = test.done || function () {};
this._description = test.description || "";
- this._runCount = test.runCount || 20;
+ this._runCount = 20;
this._callsPerIteration = 1;
this.unit = 'runs/s';