/** * Set the profiler stats into template * * @uses Profiler::groups * * @link http://php.net/manual/en/function.number-format.php number_format * @link http://php.net/manual/en/function.get-included-files.php get_included_files */ protected function _set_profiler_stats() { $queries = 0; if (Kohana::$profiling) { // DB queries foreach (Profiler::groups() as $group => $benchmarks) { if (strpos($group, 'database') === 0) { $queries += count($benchmarks); } } } // HHVM's reported memory usage from memory_get_peak_usage() // is not useful when passing false, but we continue passing // false for consistency of historical data in zend. $realMemoryUsage = Request::isHHVM(); // Get the total memory and execution time $total = array('{memory_usage}' => number_format((memory_get_peak_usage($realMemoryUsage) - GLEEZ_START_MEMORY) / 1024 / 1024, 2) . ' ' . __('MB'), '{gleez_version}' => Gleez::VERSION, '{execution_time}' => number_format(microtime(TRUE) - GLEEZ_START_TIME, 3) . ' ' . __('seconds'), '{included_files}' => count(get_included_files()), '{database_queries}' => $queries); // Insert the totals into the response $this->template = strtr((string) $this->template, $total); }
/** * Inline exception handler, displays the error message, source of the * exception, and the stack trace of the error. * * @param Exception $e Exception * @link https://github.com/facebook/hhvm/issues/4055 * @link https://github.com/facebook/hhvm/issues/993 */ public static function handler(Exception $e) { $response = self::_handler($e); // Send the response to the browser echo $response->send_headers()->body(); if (!Request::isHHVM()) { exit(1); } }