blob: 4278f02474865994bd1a25bbb8889bb0fb35ec49 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<div id="description"></div>
<div id="console"></div>
<script src="../../../resources/js-test-pre.js"></script>
<script src="../../../../PerformanceTests/resources/runner.js"></script>
<script type="text/javascript">
description("This test verifies PerfTestRunner.runPerSecond() calls runFunction as many times as expected.");
var iteration = 0;
var currentTime = 100;
var callsInIterations = [];
var timesInIterations = [0, 10, 30, 60, 200, 200, 200, 200, 750];
var logLines = [];
PerfTestRunner.now = function () {
iteration++;
if (iteration % 2 == 0)
currentTime += timesInIterations.shift();
return currentTime;
}
PerfTestRunner.log = function (line) { logLines.push(line); }
var originalTimesInIterations = timesInIterations.slice();
PerfTestRunner.measureRunsPerSecond({
run: function () {
var i = Math.floor(iteration / 2);
if (callsInIterations[i] == undefined)
callsInIterations[i] = 0;
callsInIterations[i]++;
},
customIterationCount: 1,
done: function () {
debug("Returning times: [" + originalTimesInIterations.join(", ") + "]");
shouldEvaluateTo("callsInIterations[0]", 1);
shouldEvaluateTo("callsInIterations[1]", 10);
shouldBeTrue("callsInIterations[1] + 5 < callsInIterations[2]");
shouldBeTrue("callsInIterations[2] + 10 < callsInIterations[3]");
shouldBe("callsInIterations[3]", "callsInIterations[4]");
shouldBe("callsInIterations[4]", "callsInIterations[5]");
shouldBe("callsInIterations[5]", "callsInIterations[6]");
shouldBe("callsInIterations[6]", "callsInIterations[7]");
shouldBe("callsInIterations[7]", "callsInIterations[8]");
shouldBeUndefined("callsInIterations[9]");
}});
var jsTestIsAsync = true;
</script>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>