コード例 #1
0
ファイル: profiler.php プロジェクト: alexqwert/kanon
 public function html()
 {
     $h = '<div class="kanon-profiler">';
     if (function_exists('xdebug_get_profiler_filename')) {
         $h .= '<div>XDebug: ' . xdebug_get_profiler_filename() . '</div>';
     }
     $h .= '<div>Total queries: ' . count($this->_sql) . '</div>';
     $totalSqlTime = 0;
     foreach ($this->_sql as $sqlInfo) {
         $totalSqlTime += $sqlInfo['time'];
     }
     $h .= '<div>Total runtime: ' . number_format(microtime(true) - self::$_enableTime, 6, '.', '') . '</div>';
     $h .= '<div>Total time: ' . number_format($totalSqlTime, 6, '.', '') . '</div>';
     $h .= '<table width="100%" class="sql">';
     foreach ($this->_sql as $sqlInfo) {
         $h .= '<tr><td>';
         $h .= '<strong style="font-weight: normal;color: #ddd;">' . htmlspecialchars($sqlInfo['sql']) . '</strong>';
         $h .= '<div>';
         if ($sqlInfo['time'] > 0.01) {
             $h .= '<span style="color: #f00">';
         }
         $h .= 'Time: ' . number_format($sqlInfo['time'], 6, '.', '');
         if ($sqlInfo['time'] > 0.01) {
             $h .= '</span>';
         }
         $h .= ' Start: ' . number_format($sqlInfo['start'] - self::$_enableTime, 6, '.', '');
         if ($traceInfo = $this->_getTraceController($sqlInfo['trace'])) {
             $h .= ' ' . $traceInfo['class'] . $traceInfo['type'] . $traceInfo['function'] . '() at line ' . $traceInfo['line'];
         }
         $i = 0;
         $skip = array('profiler', 'mysqlDriver', 'storageDriver', 'modelStorage', 'modelExpression', 'modelQueryBuilder', 'modelResultSet');
         foreach ($sqlInfo['trace'] as $traceInfo) {
             if (in_array($traceInfo['class'], $skip)) {
                 array_shift($sqlInfo['trace']);
             } else {
                 break;
             }
         }
         foreach ($sqlInfo['trace'] as $traceInfo) {
             $i++;
             $h .= '<div style="line-height: 1em;font-size:10px;">';
             $h .= '#' . $i . ' ' . $traceInfo['class'] . $traceInfo['type'] . $traceInfo['function'] . '() at line ' . $traceInfo['line'];
             $h .= '</div>';
         }
         $h .= '</div>';
         $h .= '</td></tr>';
     }
     $h .= '</table>';
     $h .= yProfiler::html();
     return $h . '</div>';
 }