Here is a function that times execution of any piece of PHP code, much like Python's timeit module does: https://gist.github.com/flaviovs/35aab0e85852e548a60a
How to use it:
include('timeit.php');
const SOME_CODE = '
strlen("foo bar");
';
$t = timeit(SOME_CODE);
print "$t[0] loops; $t[2] per loop\n";
Result:
$ php x.php
100000 loops; 18.08us per loop
Disclaimer: I am the author of this Gist
EDIT: timeit is now a separate, self-contained project at https://github.com/flaviovs/timeit