includes/functions.php
changeset 424 f58e0b6e9c22
parent 411 d1a95497b68f
child 436 242353360e37
equal deleted inserted replaced
423:990ccfb20120 424:f58e0b6e9c22
  4022     return false;
  4022     return false;
  4023   
  4023   
  4024   $_profiler[] = array(
  4024   $_profiler[] = array(
  4025       'point' => 'Profiling started',
  4025       'point' => 'Profiling started',
  4026       'time' => microtime_float(),
  4026       'time' => microtime_float(),
  4027       'backtrace' => false
  4027       'backtrace' => false,
       
  4028       'mem' => false
  4028     );
  4029     );
       
  4030   if ( function_exists('memory_get_usage') )
       
  4031   {
       
  4032     $_profiler[ count($_profiler) - 1 ]['mem'] = memory_get_usage();
       
  4033   }
  4029 }
  4034 }
  4030 
  4035 
  4031 /**
  4036 /**
  4032  * Logs something in the profiler.
  4037  * Logs something in the profiler.
  4033  * @param string Point name or message
  4038  * @param string Point name or message
  4046     list(, $backtrace) = explode("\n", enano_debug_print_backtrace(true));
  4051     list(, $backtrace) = explode("\n", enano_debug_print_backtrace(true));
  4047   }
  4052   }
  4048   $_profiler[] = array(
  4053   $_profiler[] = array(
  4049       'point' => $point,
  4054       'point' => $point,
  4050       'time' => microtime_float(),
  4055       'time' => microtime_float(),
  4051       'backtrace' => $backtrace
  4056       'backtrace' => $backtrace,
       
  4057       'mem' => false
  4052     );
  4058     );
       
  4059   if ( function_exists('memory_get_usage') )
       
  4060   {
       
  4061     $_profiler[ count($_profiler) - 1 ]['mem'] = memory_get_usage();
       
  4062   }
  4053 }
  4063 }
  4054 
  4064 
  4055 /**
  4065 /**
  4056  * Returns the profiler's data (so far).
  4066  * Returns the profiler's data (so far).
  4057  * @return array
  4067  * @return array
  4112       $html .= '  <td class="row2">Called from:</td>' . "\n";
  4122       $html .= '  <td class="row2">Called from:</td>' . "\n";
  4113       $html .= '  <td class="row1">' . htmlspecialchars($entry['backtrace']) . '</td>' . "\n";
  4123       $html .= '  <td class="row1">' . htmlspecialchars($entry['backtrace']) . '</td>' . "\n";
  4114       $html .= '</tr>' . "\n";
  4124       $html .= '</tr>' . "\n";
  4115     }
  4125     }
  4116     
  4126     
       
  4127     if ( $entry['mem'] )
       
  4128     {
       
  4129       $html .= '<tr>' . "\n";
       
  4130       $html .= '  <td class="row2">Total mem usage:</td>' . "\n";
       
  4131       $html .= '  <td class="row1">' . htmlspecialchars($entry['mem']) . ' (bytes)</td>' . "\n";
       
  4132       $html .= '</tr>' . "\n";
       
  4133     }
       
  4134     
  4117     $html .= "\n";
  4135     $html .= "\n";
  4118     
  4136     
  4119     $time_last = $entry['time'];
  4137     $time_last = $entry['time'];
  4120   }
  4138   }
  4121   $html .= '</table></div>';
  4139   $html .= '</table></div>';