Benchmarking a script

From: Date: Wed, 23 Jun 2004 08:36:11 +0000
Subject: Benchmarking a script
Groups: php.general 
Request: Send a blank email to php-general+get-188855@lists.php.net to get a copy of this message
Hello, I have a script I am optimizing and want to compare the before and after in speed. So I wrote a few lines to loop this script but I have a problem. In the script I'm optimizing there's some function definitions and when the script starts the second iteration it throws an error because the function already exists. How can I modify my benchmark code to make it work? This is what I have: <?php $bench_n = 1000; for($bench_i=$bench_n; --$bench_i>=0; ){ ob_start(); $bench_time1 = array_sum(explode(' ', microtime())); // script start ************************************ // script... // script end ************************************** $bench_time0 += array_sum(explode(' ', microtime())) - $bench_time1; while(@ob_end_clean()); }
echo '<pre>Tot Time: ' , $bench_time0 , '<br />Loops:    ' , $bench_n , '<br />Avg Time: ' , ($bench_time0 / $bench_n) , '</pre>';
?> Thank you very much in advance. Cristian

« previous php.general (#188855) next »