Skip to content

Commit

Permalink
FEATURE: allow to fetch number of DB queries
Browse files Browse the repository at this point in the history
  • Loading branch information
skurfuerst committed Feb 2, 2017
1 parent c2ce819 commit 02c653f
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions Classes/Sandstorm/PhpProfiler/Domain/Model/ProfilingRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,40 @@ public function getMemory()
return $output;
}

/**
* Get DB Queries. Returned is a sorted-by-time array
* where each array element is again an array with the following structure:
*
* 'time' => (float) Current time in seconds, with microtime precision; relative to $this->startTime
* 'dbQueryCount' => (int) Number of DB queries done so far.
*
* @return array
*/
public function getDbQueryCount()
{
$output = array();
foreach ($this->timestamps as $t) {
$output[] = array(
'time' => $t['time'],
'dbQueryCount' => $t['dbQueryCount']
);
}
foreach ($this->timers as $tmp) {
foreach ($tmp as $t) {
$output[] = array(
'time' => $t['time'],
'dbQueryCount' => $t['dbQueryCount']
);
}
}

// now, sort events by start time
usort($output, function ($a, $b) {
return (int)(1000 * $a['time'] - 1000 * $b['time']);
});
return $output;
}

/**
* Get the full XHProf Trace array
*
Expand Down

0 comments on commit 02c653f

Please sign in to comment.