本文整理汇总了PHP中Benchmark::benchCall方法的典型用法代码示例。如果您正苦于以下问题:PHP Benchmark::benchCall方法的具体用法?PHP Benchmark::benchCall怎么用?PHP Benchmark::benchCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Benchmark
的用法示例。
在下文中一共展示了Benchmark::benchCall方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bench
public static function bench()
{
echo "Benchmark PHP-" . PHP_VERSION . PHP_EOL;
echo "OS: " . PHP_OS . PHP_EOL;
echo "Info: " . php_uname('a') . PHP_EOL;
echo str_repeat('=', 40) . PHP_EOL;
$max = -10;
$min = 10;
$count = 14000000;
$rounds = 10;
$class = new Benchmark();
$allStatistics = array();
for ($i = 0; $i < $rounds; $i++) {
self::$statistics = [];
$total = 0;
echo "Round " . ($i + 1) . "...." . PHP_EOL;
$total += Benchmark::benchCall($class, 'math', $count);
$total += Benchmark::benchCall($class, 'methodCallEmpty', $count);
$total += Benchmark::benchCall($class, 'methodCallBool', $count);
$count = 140000;
$total += Benchmark::benchCall($class, 'arrayAppendInt', $count);
$total += Benchmark::benchCall($class, 'arrayAppendString', $count);
$total += Benchmark::benchCall($class, 'readClassConst', $count);
$total += Benchmark::benchCall($class, 'readClassConstBySelf', $count);
echo "end" . PHP_EOL;
echo PHP_EOL;
$min = min($min, $total);
$max = max($max, $total);
$allStatistics[] = self::$statistics;
}
$table = new Table();
$table->setHeaders(array('Test', 'Min', 'Max', 'Avg'));
foreach ($allStatistics[0] as $key => $row) {
$minRow = 10;
$maxRow = -10;
$avgRow = 0;
for ($i = 0; $i < $rounds; $i++) {
$value = $allStatistics[$i][$key];
$minRow = min($minRow, $value);
$maxRow = max($maxRow, $value);
$avgRow += $value;
}
$table->addRow([$key, $minRow, $maxRow, $avgRow / $rounds]);
}
/**
* 0.1 - 60 000
* $min -
*/
$perfect = 0.1;
$perfectScore = 60000;
echo str_repeat('=', 40) . PHP_EOL . PHP_EOL;
$table->printTable();
echo PHP_EOL;
echo "Max: " . $max . PHP_EOL;
echo "Min: " . $min . PHP_EOL;
$score = $perfect / $min * $perfectScore;
echo "Score: " . number_format($score, 0, ' ', 'k') . PHP_EOL;
}