Browse Source

Profiler getCli() method added

master
Anton Terekhov 13 years ago
parent
commit
642c5909aa
  1. 16
      util/profiler/Profiler.php

16
util/profiler/Profiler.php

@ -101,4 +101,20 @@ class Profiler
}
FB::table('Queries: ' . count($this->queries) . ' [' . round($queriesTime * 1000, 2) . ' ms]', $table);
}
public function getCli()
{
$this->end = microtime(true);
$queriesTime = 0;
$temp = str_pad(PHP_EOL, 60, '-', STR_PAD_LEFT);
foreach ($this->queries as $query) {
$temp .= sprintf('%-25s[% 10sms] %s', '(' . $query->getType() .')', round($query->getElapsed() * 1000, 2), $query->getCommand()) . PHP_EOL;
$queriesTime += $query->getElapsed();
}
$html = str_pad(PHP_EOL, 60, '-', STR_PAD_LEFT);
$html .= 'Elapsed time: ' . round(($this->end - $this->start) * 1000, 2) . 'ms.' . PHP_EOL
. 'Queries: ' . count($this->queries) . ' [' . round($queriesTime * 1000, 2) . ' ms] ' . PHP_EOL;
$html .= $temp;
return $html;
}
}
Loading…
Cancel
Save