Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- ##########################################################################
- # PHP Benchmark Performance Script #
- # © 2010 Code24 BV #
- # #
- # Author : Alessandro Torrisi #
- # Company : Code24 BV, The Netherlands #
- # Date : July 31, 2010 #
- # version : 1.0 #
- # License : Creative Commons CC-BY license #
- # Website : http://www.php-benchmark-script.com #
- # #
- ##########################################################################
- */
- $multiplier = 1;
- if (!empty($_GET['m'])){
- $multiplier = $_GET['m'];
- }
- if ($multiplier > 100){
- die('To high m (Max 100)');
- }
- function test_Loops($count = 4000000) {
- global $multiplier;
- $count = $count * $multiplier;
- $time_start = microtime(true);
- for($i = 0; $i < $count; ++$i);
- $i = 0; while($i < $count) ++$i;
- return number_format(microtime(true) - $time_start, 3);
- }
- function test_IfElse($count = 2000000) {
- global $multiplier;
- $count = $count * $multiplier;
- $time_start = microtime(true);
- for ($i=0; $i < $count; $i++) {
- if ($i == -1) {
- } elseif ($i == -2) {
- } else if ($i == -3) {
- }
- }
- return number_format(microtime(true) - $time_start, 3);
- }
- $total = 0;
- $functions = get_defined_functions();
- $line = str_pad("-",38,"-");
- echo "<pre>$line\n|".str_pad("PHP BENCHMARK SCRIPT",36," ",STR_PAD_BOTH)."|\n$line\nStart : ".date("Y-m-d H:i:s")."\nServer : {$_SERVER['SERVER_NAME']}@{$_SERVER['SERVER_ADDR']}\nPHP version : ".PHP_VERSION."\nPlatform : ".PHP_OS. "\n$line\n";
- foreach ($functions['user'] as $user) {
- if (preg_match('/^test_/', $user)) {
- $total += $result = $user();
- echo str_pad($user, 25) . " : " . $result ." sec.\n";
- }
- }
- echo str_pad("-", 38, "-") . "\n" . str_pad("Total time:", 25) . " : " . $total ." sec.</pre>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement