Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- /*
- * How to Use
- *
- * -- Create an empty time-holder array and add in start time
- * $t = array();
- * $t['start'] = microtime(true);
- * -- Do operation, then add in time afterwards
- * sleep(1);
- * $t['after_sleep'] = microtime(true);
- * -- Do other operations and add in times, then finally echo out the function
- * echo mini_bench_to($t);
- */
- function mini_bench($arg_t, $arg_ra=false) {
- $tttime=round((end($arg_t)-$arg_t['start'])*1000,4);
- if ($arg_ra) $ar_aff['total_time']=$tttime;
- else $aff="total time : ".$tttime."ms\n";
- $prv_cle='start';
- $prv_val=$arg_t['start'];
- foreach ($arg_t as $cle=>$val) {
- if($cle!='start') {
- $prcnt_t=round(((round(($val-$prv_val)*1000,4)/$tttime)*100),1);
- if ($arg_ra) $ar_aff[$prv_cle.' -> '.$cle]=$prcnt_t;
- $aff.=$prv_cle.' -> '.$cle.' : '.$prcnt_t." %\n";
- $prv_val=$val;
- $prv_cle=$cle;
- }
- }
- if ($arg_ra) return $ar_aff;
- return $aff;
- }
- ?>
Add Comment
Please, Sign In to add comment