Quick benchmark from the command line

If all you want is to benchmark a PHP script why not just write a unit test for it. Like:

<?php

function test() {
    require 'my_script_to_test.php';
}

for ($i = 0; $i < 1000; $i++) {
    $time = microtime(true);
    test();
    $time = microtime(true) - $time;
    echo 'test '.$i.': '.$time;
    // and then you can also average time and w/e 
}

?>

In command line, you can:

$ time php foobar.php

Here time is a bash built-in.

For multiple runs:

$ time for a in {1..10}; do php foobar.php; done
real    0m13.042s
user    0m0.021s
sys     0m0.044s

However, you need to calculate the average time by hand.