Ejemplo n.º 1
0
$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();
for ($i = 0; $i < $run_times; $i++) {
    $z = $i % 4;
    if ($z == 0) {
    } else {
        if ($z == 1) {
        } else {
Ejemplo n.º 2
0
$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);
echo 'b = ' . $b;
echo "\n" . $b - $a . "\n";
exit;
$timer->start(memory_get_usage(true));
while ($i > 0) {
    --$i;
}
$timer->stop(memory_get_usage(true), 'while');