Lavoiesl\PhpBenchmark\Benchmark::guessCount PHP Метод

guessCount() публичный Метод

Average the guessCount of each test, determining the best n
public guessCount ( float $max_seconds ) : integer
$max_seconds float
Результат integer
    public function guessCount($max_seconds)
    {
        if (!$this->tests) {
            throw new \RuntimeException('No test in Benchmark.');
        }
        $n = INF;
        foreach ($this->tests as $test) {
            $n = min($n, $test->guessCount($max_seconds));
        }
        return $this->n = Util::round($n);
    }

Usage Example

Пример #1
0
<?php

use Lavoiesl\PhpBenchmark\Benchmark;
require_once '_autoload.php';
$benchmark = new Benchmark();
// @link http://www.php.net/manual/en/control-structures.declare.php#control-structures.declare.ticks
declare (ticks=1);
$benchmark->add('1024 * 256', function () {
    return str_repeat('a', 1024 * 256);
});
$benchmark->add('1024 * 1024', function () {
    return str_repeat('a', 1024 * 1024);
});
$benchmark->add('1024 * 1024 * 16', function () {
    return str_repeat('a', 1024 * 1024 * 16);
});
$benchmark->guessCount(2);
// aim for 2 seconds per test (default)
$benchmark->run();