std/profiler.inc.php

00001 <?php if(!function_exists('startedIndexPhp')) { header("location:../index.php"); exit();}
00002 # streber - a php5 based project management system  (c) 2005-2007  / www.streber-pm.org
00003 # Distributed under the terms and conditions of the GPL as stated in lang/license.html
00004 
00022 $measure_times=array();
00023 $measure_counts=array();
00024 $measure_times_started=array();
00025 $time_total=1;
00026 
00030 function measure_start($id) {
00031     global $measure_times_started;
00032     global $measure_counts;
00033     global $measure_times;
00034     if(!isset($measure_times_started[$id])) {
00035         $measure_times_started[$id]=microtime(1);
00036     }
00037     if(isset($measure_counts[$id])) {
00038         $measure_counts[$id]++;
00039     }
00040     else {
00041         $measure_counts[$id]=1;
00042     }
00043     if(!isset($measure_times[$id])) {
00044         $measure_times[$id]=0;
00045     }
00046 }
00047 
00051 function measure_stop($id){
00052     global $measure_times_started;
00053     global $measure_times;
00054     if($tmp= @$measure_times_started[$id]) {
00055         $time=microtime(1) - $tmp;
00056         if(@$measure_times[$id]) {
00057             if($time>0) {
00058                 $measure_times[$id]+=$time;
00059             }
00060         }
00061         else {
00062             $measure_times[$id]=$time;
00063         }
00064     }
00065     unset($measure_times_started[$id]);
00066 }
00067 
00071 function render_measures() {
00072     global $measure_times;
00073     global $measure_counts;
00074     global $time_total;
00075     measure_stop('time_complete');
00076     $buffer='<table>';
00077     foreach($measure_times as $key=>$time) {
00078         $width= round($time/$time_total*100,0)."px";
00079         $time_ms=round($time*1000,0);
00080         $buffer.="<tr>";
00081         $buffer.=
00082             "<td>$key </td>".
00083             "<td>$time_ms</td>".
00084             '<td><img src="themes/'.getCurTheme().'/img/pixel.gif" style="height:3px;width:'.$width.'; background-color:#f00;"></td>';
00085         $buffer.="</tr>";
00086     }
00087     $buffer.='</table>';
00088     return $buffer;
00089 }
00090 ?>

Generated on Sun Mar 4 17:19:32 2007 for streber by  doxygen 1.5.1-p1