예제 #1
0
파일: 02-fibo.php 프로젝트: bwoebi/recki-ct
 *
 * @param int $n The number of the sequence to generate
 *
 * @return int the fibonacci number!
 */
function fibo($n)
{
    if ($n < 2) {
        return 1;
    }
    return fibo($n - 1) + fibo($n - 2);
}
/**
 * Compile the function using the JITFU extension!
 */
$func = Jit::jitfu('fibo');
/**
 * Now let's benchmark the two implementations!
 *
 * If you don't have JitFu installed, then both should be equal.
 */
benchmark("fibo", "PHP");
benchmark($func, "ReckiCT");
/**
 * A very light weight benchmark tool, which runs the code 100,000 times.
 *
 * For a function that's as CPU intensive as this, Recki-CT should already
 * be orders of magnitude faster than PHP.
 *
 * @param callable $func  The function to benchmark
 * @param string   $label The label of the test, for output
예제 #2
0
 * @param int $n The parameter
 *
 * @return int The parameter, returned
 */
function test($n)
{
    return $n;
}
/**
 * Compile the function using the JITFU extension!
 *
 * Note that if the JITFU extension isn't installed, this will simply
 * return a "callable" string (the function name). So you can use it portably
 * across installations.
 */
$func = Jit::jitfu('test');
/**
 * Now let's benchmark the two implementations!
 *
 * If you don't have JitFu installed, then both should be equal.
 */
benchmark("test", "PHP");
benchmark($func, "ReckiCT");
/**
 * A very light weight benchmark tool, which runs the code 100,000 times.
 *
 * For very simple functions like the one we are testing here, we don't expect
 * a lot of gain (if any), since the overhead of the functional call will dominate
 * the runtime.
 *
 * @param callable $func  The function to benchmark