From 642c5909aa257d8c693364b3b8c0ca5195db1f04 Mon Sep 17 00:00:00 2001 From: Anton Terekhov Date: Fri, 7 Oct 2011 15:17:12 +0400 Subject: [PATCH] Profiler getCli() method added --- util/profiler/Profiler.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/util/profiler/Profiler.php b/util/profiler/Profiler.php index cea0bdc..0f423e2 100644 --- a/util/profiler/Profiler.php +++ b/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; + } } \ No newline at end of file