Exemple #1
0
    return $t['sec'] + $t['usec'] / 1000000;
}
function start_test()
{
    ob_start();
    return getmicrotime();
}
function end_test($start, $name)
{
    global $total;
    $end = getmicrotime();
    ob_end_clean();
    $total += $end - $start;
    $num = number_format($end - $start, 3);
    $pad = str_repeat(" ", 24 - strlen($name) - strlen($num));
    echo $name . $pad . $num . "\n";
    ob_start();
    return getmicrotime();
}
function total()
{
    global $total;
    $pad = str_repeat("-", 24);
    echo $pad . "\n";
    $num = number_format($total, 3);
    $pad = str_repeat(" ", 24 - strlen("Total") - strlen($num));
    echo "Total" . $pad . $num . "\n";
}
$t0 = $t = start_test();
hash1(590000);
$t = end_test($t, "hash1(50000)");
Exemple #2
0
    $pad = str_repeat(" ", 24 - strlen($name) - strlen($num));
    echo $name . $pad . $num . "\n";
    ob_start();
    return getmicrotime();
}
function total()
{
    global $total;
    $pad = str_repeat("-", 24);
    echo $pad . "\n";
    $num = number_format($total, 3);
    $pad = str_repeat(" ", 24 - strlen("Total") - strlen($num));
    echo "Total" . $pad . $num . "\n";
}
$total = 0;
$t0 = start_test();
$t = $t0;
simple();
$t = end_test($t, "simple");
simplecall();
$t = end_test($t, "simplecall");
simpleucall();
$t = end_test($t, "simpleucall");
simpleudcall();
$t = end_test($t, "simpleudcall");
mandel();
$t = end_test($t, "mandel");
mandel2();
$t = end_test($t, "mandel2");
ackermann(7);
$t = end_test($t, "ackermann(7)");
Exemple #3
0
function main()
{
    $tests = array("simple", "simplecall", "simpleucall", "simpleudcall", "mandel", "ackermann", "ary", "ary2", "ary3", "fibo", "hash2", "heapsort", "nestedloop", "sieve", "strcat", "binary_trees", "fannkuch", "fasta", "mandelbrot", "meteor_contest", "n_body", "spectral_norm");
    $t0 = $t = start_test();
    foreach ($tests as $test) {
        //    if (!isset($argv[1]) || $argv[1] === $test) {
        $test();
        $t = end_test($t, $test);
        //}
    }
    //if (!getenv('VERIFY')) {
    total();
    //}
}
Exemple #4
0
    }
    ob_start();
    return microtime(true);
}
function total()
{
    global $total;
    $pad = str_repeat("-", 24);
    echo $pad . "\n";
    $num = number_format($total, 3);
    $pad = str_repeat(" ", 24 - strlen("Total") - strlen($num));
    echo "Total" . $pad . $num . "\n";
}
const N = 5000000;
echo "Benchmark Zephir " . \Zephir\Compiler::VERSION . " \n";
$t = start_test();
$x = new \Test\Bench\Foo();
$x->empty_for_in_range(N);
$t = end_test($t, 'empty for in range');
$x->read_prop(N);
$t = end_test($t, '$x = $this->x');
$x->write_prop(N);
$t = end_test($t, '$this->x = 0');
$x->assign_add_prop(N);
$t = end_test($t, '$this->x += 2');
//$x->pre_inc_prop(N);
//$t = end_test($t, '++$this->x');
//$x->pre_dec_prop(N);
//$t = end_test($t, '--$this->x');
$x->post_inc_prop(N);
$t = end_test($t, '$this->x++');
Exemple #5
0
<?php

// hand reduced from zend bench.php. This found memory coruption.
function simple()
{
}
function getmicrotime()
{
    $t = gettimeofday();
}
function start_test()
{
    return getmicrotime();
}
start_test();
simple();
$x = $y + $z;