<!DOCTYPE html>
<html>
<body>
<p id="description">This test verifies PerfTestRunner.runPerSecond() outputs log as expected.</p>
<div id="console"></div>
<script src="../../../../PerformanceTests/resources/runner.js"></script>
<script type="text/javascript">

var logLines = [];
var initial = true;
var runs = 0;

var iteration = 0;
var currentTime = 0;

PerfTestRunner.now = function () {
    iteration++;
    if (iteration % 2 == 0)
        currentTime += 1000 / runs;
    return currentTime;
}

PerfTestRunner.storeHeapResults = function () { }

var logStatistics = PerfTestRunner.logStatistics;
PerfTestRunner.logStatistics = function (statistics, unit, title) {
    if (unit == 'bytes')
        return;
    return logStatistics.call(PerfTestRunner, statistics, unit, title);
}

var computeStatistics = PerfTestRunner.computeStatistics;
PerfTestRunner.computeStatistics = function (values, unit) {
    var statistics = computeStatistics(values, unit);
    if (statistics.stdev)
        statistics.stdev = statistics.stdev.toPrecision(3);
    return statistics;
}

PerfTestRunner.measureRunsPerSecond({
    setup: function () {
        runs++;
        // Avoid 3, 6, 7, 9.
        if (runs == 6)
            runs += 2;
        else if (!(runs % 3))
            runs++;
    },
    run: function () { },
    iterationCount: 5,
});

</script>
</body>
</html>
