当前位置: 首页>>代码示例>>PHP>>正文


PHP Benchmark::benchCall方法代码示例

本文整理汇总了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;
 }
开发者ID:noikiy,项目名称:php-zephir-hhvm-benchmark,代码行数:58,代码来源:benchmark.php


注:本文中的Benchmark::benchCall方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。