Exemplo n.º 1
0
 /**
  * Collects and aggregates data recorded by Profiler_Console.
  */
 public function gatherConsoleData()
 {
     $logs = Profiler_Console::getLogs();
     foreach ($logs as $type => $data) {
         // Console data will already be properly formatted.
         if ($type == 'console') {
             continue;
         }
         // Ignore empty message lists
         if (!$data['count']) {
             continue;
         }
         foreach ($data['messages'] as $message) {
             $data = $message;
             switch ($type) {
                 case 'logs':
                     $data['type'] = 'log';
                     $data['data'] = print_r($message['data'], true);
                     break;
                 case 'memory':
                     $data['type'] = 'memory';
                     $data['data'] = $this->getReadableFileSize($data['data']);
                     break;
                 case 'speed':
                     $data['type'] = 'speed';
                     $data['data'] = $this->getReadableTime(($message['data'] - $this->startTime) * 1000);
                     break;
                 case 'benchmarks':
                     $data['type'] = 'benchmark';
                     $data['data'] = $this->getReadableTime($message['end_time'] - $message['start_time']);
                     break;
             }
             if (isset($data['type'])) {
                 $logs['console']['messages'][] = $data;
             }
         }
     }
     $this->output['logs'] = $logs;
 }