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; } } set_time_limit(0); ini_set('memory_limit', '256M'); Benchmark::bench();
$words = explode(' ', $paragraph); // Create a bunch of letter entries $sequence = array(); for ($j = 0; $j < $elementNumber; $j++) { $sequence[] = 'a' . $j; } $s = microtime(true); for ($j = 0; $j < $total; $j++) { foreach ($words as $word) { in_array(strtolower($word), $sequence); } } echo "in_array: " . (microtime(true) - $s) . "\n"; // Convert the array to a hash Hashee::addBulk($sequence); $s = microtime(true); for ($j = 0; $j < $total; $j++) { foreach ($words as $word) { Hashee::in($word, $sequence); } } echo "hashee: " . (microtime(true) - $s) . "\n"; echo "========================================\n"; } } $benchmark = new Benchmark(); $benchmark->bench(5); $benchmark->bench(10); $benchmark->bench(100); $benchmark->bench(1000); $benchmark->bench(10000);