I have two functions whose execution time I would like to compare:
function subject_one() {
$str = preg_match_all( ...[SNIP]... );
// ...[SNIP]...
return $str;
}
function subject_two() {
$reader = new XMLReader;
$writer = new XMLWriter;
// ...[SNIP]...
echo $str;
}
Is it possible to write a function to do this?
For example:
function benchmark_two_functions( $first_function, $second_function ) {
// do stuff
return $length_of_time_to_complete_each_function
}
Most examples I've seen add code to the top and bottom of the script, which I'd like to avoid, if possible.