<?php

// php benchmarker by Paul Taulborg (njaguar at http://forums.d2jsp.org) - Modified by Jeroen Post
$timer = new benchmarkTimer();
$head = str_pad("#", 36, "#");
echo "<pre>" . str_pad(' PHP ' . PHP_VERSION . ' BENCHMARK ', 36, "#", STR_PAD_BOTH) . "\nStart : " . date("m/d/Y H:i:s a") . "\nServer : {$_SERVER['SERVER_NAME']}@{$_SERVER['SERVER_ADDR']}\nPlatform : " . PHP_OS . "\nPHP version: " . phpversion() . "\n{$head}\n";
$run_times = 1000000;
$run_times_slow_function = 10000;
$string_1 = 'bob & jim & tim & kim & me & you are &&&& =%"';
$string_2 = '     what      ';
$string_3 = strtoupper($string_1);
$string_4 = '1234a';
$string_5 = '64x32';
$string_6 = 'this is a link to http://google.com which is a really popular site';
$string_7 = 'number %d is like a string %s that likes to hex %x it out';
$string_8 = $string_7 . ' and then some';
$string_9 = 'quotes\'are "fun" to use\'. Most of the time. \\ ya';
$array_1 = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' => 1, 'i' => 2, 'j' => 0);
$array_2 = array('coffee', 'brown', 'caffeine');
$time_1 = '12/29/2011 10:15:37pm';
$now = time();
$timer->start();
for ($i = 0; $i < $run_times; ++$i) {
}
$timer->stop('for');
$timer->start();
while ($i > 0) {
    --$i;
}
$timer->stop('while');
$timer->start();
Exemple #2
0
<?php

// php benchmarker by Paul Taulborg (njaguar at http://forums.d2jsp.org) - Modified by Jeroen Post
$timer = new benchmarkTimer();
$head = str_pad("#", 36, "#");
echo "<pre>" . str_pad(' PHP ' . PHP_VERSION . ' BENCHMARK ', 36, "#", STR_PAD_BOTH) . "\nStart : " . date("m/d/Y H:i:s a") . "\nServer : {$_SERVER['SERVER_NAME']}@{$_SERVER['SERVER_ADDR']}\nPlatform : " . PHP_OS . "\nPHP version: " . phpversion() . "\n{$head}\n";
$run_times = 1000000;
// 1million
$run_times_slow_function = 10000;
// 10 000
$string_1 = 'bob & jim & tim & kim & me & you are &&&& =%"';
$string_2 = '     what      ';
$string_3 = strtoupper($string_1);
$string_4 = '1234a';
$string_5 = '64x32';
$string_6 = 'this is a link to http://google.com which is a really popular site';
$string_7 = 'number %d is like a string %s that likes to hex %x it out';
$string_8 = $string_7 . ' and then some';
$string_9 = 'quotes\'are "fun" to use\'. Most of the time. \\ ya';
$array_1 = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h' => 1, 'i' => 2, 'j' => 0);
$array_2 = array('coffee', 'brown', 'caffeine');
$time_1 = '12/29/2011 10:15:37pm';
$now = time();
$timer->start(memory_get_usage(true));
$a = memory_get_usage(true);
echo 'a=' . $a . "\n";
for ($i = 0; $i < $run_times; ++$i) {
}
echo 'peak = ' . memory_get_peak_usage(true) . "\n";
$timer->stop(memory_get_usage(true), 'for');
$b = memory_get_usage(true);