public function addTimeEventInfo(StopwatchEvent $timeEvent = null) { if (!$timeEvent) { return $this; } // Contiene i dati sui tempi di esecuzione $timeInfoArray = array('exec_time' => new DbgInfoItem('exec_time', $timeEvent ? $timeEvent->getDuration() : 0, DbgInfoItem::TYPE_NUMERIC), 'memory_usage' => new DbgInfoItem('exec_mem', $timeEvent ? $timeEvent->getMemory() : 0, DbgInfoItem::TYPE_MEMSIZE)); return $this->add('system_info', new DbgInfoArrayItem('System usage info', $timeInfoArray, array('render_type' => 'list'))); }
/** * @param $name * @param $dialect * @param StopwatchEvent $event * @param $output * @param $peakMemory */ public function __construct($name, $dialect, StopwatchEvent $event, $output, $peakMemory) { $this->name = $name; $this->output = $output; $this->duration = $event->getDuration(); $this->memory = $event->getMemory(); $this->peakMemory = $peakMemory; $this->dialect = $dialect; }
/** * Extract StopWatch data into an array. * * @param StopwatchEvent $stopWatchEvent * @param OutputInterface|null $output * @param array $extra * * @return array */ private function extractLog(StopwatchEvent $stopWatchEvent, OutputInterface $output = null, $extra = array()) { $duration = $stopWatchEvent->getDuration() / 1000; $end = time(); $start = $end - $duration; $memory = $stopWatchEvent->getMemory() / 1048576; // Returns the max memory usage of all periods $log = array('start' => $start, 'end' => $end, 'duration' => $duration, 'memory' => $memory, 'extra' => json_encode($extra)); if (null !== $output) { $output->writeln(sprintf("=== Start time : <info>%s</info>", date('d/m/Y H:i:s', $log['start']))); $output->writeln(sprintf("=== End time : <info>%s</info>", date('d/m/Y H:i:s', $log['end']))); $output->writeln(sprintf("=== Duration : <info>%s seconds</info>", $log['duration'])); $output->writeln(sprintf("=== Memory : <info>%s Mb</info>", $log['memory'])); } return $log; }
public function addTotalTimeEventInfo(StopwatchEvent $timeEvent = null) { $this->execInfos['total_exec_time'] = $timeEvent ? $timeEvent->getDuration() : -1; $this->execInfos['total_exec_mem'] = $timeEvent ? $timeEvent->getMemory() : -1; return true; }
/** * @param string $query * @param StopwatchEvent $event * @param string[] $parameters * @param string $action * @param string $mode */ protected function log($query, array $parameters, StopwatchEvent $event, $action, $mode) { $this->logger->debug($query, array('execution_time' => $event->getDuration(), 'real_memory_usage' => $event->getMemory(), 'parameters' => $parameters, 'action' => $action, 'mode' => $mode, 'backend_name' => $this->backendName)); }
protected function formatStopwatchEvent($eventName, StopwatchEvent $event, OutputInterface $output, $withMemoryUsage = false) { $duration = new DateIntervalExtended('PT0S', $event->getDuration()); if ($eventName == 'total') { $output->write('<info>Total (Full processing)</info> : '); } else { $output->write($eventName . ' : '); } $output->writeln('<comment>' . $duration->prettyFormat() . '</comment>'); if ($withMemoryUsage) { $output->writeln('Memory usage : <comment>' . Memory::convert($event->getMemory()) . '</comment>'); } }
/** * @param StopwatchEvent $event * * @return string */ private function formatStopwatchEvent(StopwatchEvent $event) { return sprintf('Time: %s, Memory: %s.', Helper::formatTime($event->getDuration() / 1000), Helper::formatMemory($event->getMemory())); }