performance tests should be able to measure runs/sec rather than time
[WebKit-https.git] / LayoutTests / fast / harness / perftests / runs-per-second-iterations.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <div id="description"></div>
5 <div id="console"></div>
6 <script src="../../../fast/js/resources/js-test-pre.js"></script>
7 <script src="../../../../PerformanceTests/resources/runner.js"></script>
8 <script type="text/javascript">
9
10 description("This test verifies PerfTestRunner.runPerSecond() calls runFunction as many times as expected.");
11
12 var iteration = 0;
13
14 var callsInIterations = [];
15 var timesInIterations = [0, 10, 30, 60, 100, 100, 100, 100, 500];
16 var logLines = [];
17
18 PerfTestRunner.log = function (line) { logLines.push(line); }
19 PerfTestRunner._perSecondRunnerIterator = function (callsPerIteration) {
20     callsInIterations[iteration] = callsPerIteration;
21     return timesInIterations[iteration++];
22 }
23
24 PerfTestRunner.runPerSecond({
25     run: function () { },
26     runCount: 1,
27     timeToRun: 500,
28     done: function () {
29         debug("Returning times: [" + timesInIterations.join(", ") + "]");
30         shouldEvaluateTo("callsInIterations[0]", 1);
31         shouldEvaluateTo("callsInIterations[1]", 10);
32         shouldBeTrue("callsInIterations[1] + 5 < callsInIterations[2]");
33         shouldBeTrue("callsInIterations[2] + 10 < callsInIterations[3]");
34         shouldBe("callsInIterations[3]", "callsInIterations[4]");
35         shouldBe("callsInIterations[4]", "callsInIterations[5]");
36         shouldBe("callsInIterations[5]", "callsInIterations[6]");
37         shouldBe("callsInIterations[6]", "callsInIterations[7]");
38         shouldBe("callsInIterations[7]", "callsInIterations[8]");
39         shouldBeUndefined("callsInIterations[9]");
40     }});
41
42 var jsTestIsAsync = true;
43
44 </script>
45 <script src="../../../fast/js/resources/js-test-post.js"></script>
46 </body>
47 </html>