PHP Inline Profiling

I am looking for a solution to profile my php scripts in a browser (instead of using * cachegrind)

I saw this some time ago http://particletree.com/features/php-quick-profiler/ , but I have no idea how good (or accurate) it is

tips / advice appreciated

+3
source share
4 answers

xdebug creates cachegrind files, so you probably want to avoid this. I am currently using XHProf http://mirror.facebook.net/facebook/xhprof/doc.html , as it includes an excellent web interface for viewing profiling results.

+4
source

XDebug? , , , , , .

. .

+1

Benchmark , - : , .

0

, . $TIMER['mark']=microtime(TRUE); :

<?
$TIMER['start']=microtime(TRUE);
// some code
$TIMER['q1 start']=microtime(TRUE);
  $res=mysql_query($query);
$TIMER['q1 end']=microtime(TRUE);  
// some code
$TIMER['q2 start']=microtime(TRUE);
  $res=mysql_query($query);
$TIMER['q2 end']=microtime(TRUE);  
// some code
$TIMER['pagination']=microtime(TRUE);  
?>

:

<?
if ('127.0.0.1' === $_SERVER['REMOTE_ADDR']) {
  echo "<table border=1><tr><td>name</td><td>so far</td><td>delta</td><td>per cent</td></tr>";
  reset($TIMER);
  $start=$prev=current($TIMER);
  $total=end($TIMER)-$start;
  foreach($TIMER as $name => $value) {
    $sofar=round($value-$start,3);
    $delta=round($value-$prev,3);
    $percent=round($delta/$total*100);
    echo "<tr><td>$name</td><td>$sofar</td><td>$delta</td><td>$percent</td></tr>";
    $prev=$value;
  }
    echo "</table><>";
}
?>

, xDebug, , .

0

Source: https://habr.com/ru/post/1747523/


All Articles