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