40 public function start($timerId, $time, $realMemory, $emallocMemory)
42 if (empty($this->_timers[$timerId])) {
43 $this->_timers[$timerId] = [
68 public function stop($timerId, $time, $realMemory, $emallocMemory)
70 if (empty($this->_timers[$timerId])) {
71 throw new \InvalidArgumentException(sprintf(
'Timer "%s" doesn\'t exist.', $timerId));
74 $this->_timers[$timerId][
self::TIME] += $time - $this->_timers[$timerId][
'start'];
89 public function get($timerId)
91 if (empty($this->_timers[$timerId])) {
92 throw new \InvalidArgumentException(sprintf(
'Timer "%s" doesn\'t exist.', $timerId));
94 return $this->_timers[$timerId];
105 public function fetch($timerId, $key)
107 if ($key === self::ID) {
110 if (empty($this->_timers[$timerId])) {
111 throw new \InvalidArgumentException(sprintf(
'Timer "%s" doesn\'t exist.', $timerId));
118 if (!isset($this->_timers[$timerId][$key])) {
119 throw new \InvalidArgumentException(sprintf(
'Timer "%s" doesn\'t have value for "%s".', $timerId, $key));
121 $result = $this->_timers[$timerId][$key];
122 if ($key == self::TIME && $this->_timers[$timerId][self::START] !==
false) {
140 public function clear($timerId =
null)
143 unset($this->_timers[$timerId]);
159 if (!$thresholds && !$filterPattern) {
162 $thresholds = (array)$thresholds;
164 foreach ($timerIds as $timerId) {
166 if ($filterPattern && !preg_match($filterPattern, $timerId)) {
171 foreach ($thresholds as $fetchKey => $minMatchValue) {
172 $match = $this->
fetch($timerId, $fetchKey) >= $minMatchValue;
191 $timerIds = array_keys($this->_timers);
192 if (count($timerIds) <= 2) {
199 $patternLastTimerId =
'/' . $nestingSep .
'(?:.(?!' . $nestingSep .
'))+$/';
201 $prevTimerId = $timerIds[0];
203 for (
$i = 1;
$i < count($timerIds);
$i++) {
204 $timerId = $timerIds[
$i];
212 for ($j =
$i + 1; $j < count($timerIds); $j++) {
216 $timerIds[$j] =
null;
221 $prevTimerId = preg_replace($patternLastTimerId,
'', $prevTimerId, -1,
$count);
230 $prevTimerId = $timerId;
getFilteredTimerIds(array $thresholds=null, $filterPattern=null)
stop($timerId, $time, $realMemory, $emallocMemory)
start($timerId, $time, $realMemory, $emallocMemory)