/**
 * Smarty {fetch} plugin
 *
 * Type:     function<br>
 * Name:     fetch<br>
 * Purpose:  fetch file, web or ftp data and display results
 * @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch}
 *       (Smarty online manual)
 * @author Monte Ohrt <monte at ohrt dot com>
 * @param array
 * @param Smarty
 * @return string|null if the assign parameter is passed, Smarty assigns the
 *                     result to a template variable
 */
function smarty_function_Kohana_profile($params, &$smarty)
{
    $groups = Profiler::groups();
    $profile = array();
    foreach ($groups as $group_name => $group) {
        foreach ($group as $name => $member) {
            $stats = Profiler::stats($member);
            $profile[] = array('group_name' => $group_name, 'name' => $name, 'count' => count($member), 'total_time' => $stats['total']['time'], 'min_time' => $stats['min']['time'], 'max_time' => $stats['max']['time'], 'average_time' => $stats['average']['time'], 'total_memory' => $stats['total']['memory'], 'min_memory' => $stats['min']['memory'], 'max_memory' => $stats['max']['memory'], 'average_memory' => $stats['average']['memory']);
        }
    }
    $stats = Profiler::application();
    $profile[] = array('group_name' => 'Application timings', 'name' => 'Application timings', 'count' => $stats['count'], 'total_time' => $stats['total']['time'], 'min_time' => $stats['min']['time'], 'max_time' => $stats['max']['time'], 'average_time' => $stats['average']['time'], 'total_memory' => $stats['total']['memory'], 'min_memory' => $stats['min']['memory'], 'max_memory' => $stats['max']['memory'], 'average_memory' => $stats['average']['memory']);
    $smarty->assign('Kohana_profile', $profile);
}
Ejemplo n.º 2
0
 public function __destruct()
 {
     $app = Profiler::application();
     $group = Profiler::groups();
     $table = array();
     $table[] = array('Type', 'Time (s)', 'Mem (kb)');
     foreach ($group as $rName => $route) {
         $table[] = array($rName);
         foreach ($route as $tName => $type) {
             foreach ($type as $stat) {
                 $stats = Profiler::total($stat);
                 $table[] = array($tName, number_format($stats[0], 6), number_format($stats[1] / 1024, 4));
             }
         }
     }
     $this->fire->info(Session::instance()->as_array(), 'Session');
     $this->fire->group('Stats: ' . $app['count']);
     $this->fire->info('Min:	' . number_format($app['min']['time'], 6) . 's ' . number_format($app['min']['memory'] / 1024, 4) . 'kb');
     $this->fire->info('Max:	' . number_format($app['max']['time'], 6) . 's ' . number_format($app['max']['memory'] / 1024, 4) . 'kb');
     $this->fire->info('Average: ' . number_format($app['average']['time'], 6) . 's ' . number_format($app['average']['memory'] / 1024, 4) . 'kb');
     $this->fire->info('Total:	' . number_format($app['total']['time'], 6) . 's ' . number_format($app['total']['memory'] / 1024, 4) . 'kb');
     $this->fire->groupEnd();
     //$this->fire->table('Execution stats ('.number_format($endTime, 6).'s '.number_format($endMem, 4).'kb)', $table);
 }
Ejemplo n.º 3
0
 /**
  * Print some render stats
  *
  * @return string
  */
 public static function render_stats()
 {
     $run = Profiler::application();
     $run = $run['current'];
     $queries = Profiler::groups();
     $queries = count($queries['database (default)']);
     return "Page rendered in " . Num::format($run['time'], 3) . " seconds using " . Num::format($run['memory'] / 1024 / 1024, 2) . "MB and " . $queries . " queries.";
 }
Ejemplo n.º 4
0
			</td>
			<?php 
        }
        ?>
		</tr>
		<?php 
    }
    ?>
	</table>
	<?php 
}
?>

	<table class="profiler">
		<?php 
$stats = Profiler::application();
?>
		<tr class="final mark time">
			<th class="name" rowspan="2" scope="rowgroup"><?php 
echo __('Application Execution') . ' (' . $stats['count'] . ')';
?>
</th>
			<?php 
foreach ($application_cols as $key) {
    ?>
			<td class="<?php 
    echo $key;
    ?>
"><?php 
    echo number_format($stats[$key]['time'], 6);
    ?>
Ejemplo n.º 5
0
 /**
  * @return mixed
  */
 private static function getAppTime()
 {
     $tmp = Profiler::application();
     return $tmp['current']['time'];
 }
Ejemplo n.º 6
0
 public function fetch_data()
 {
     return array('stats' => Profiler::application(), 'application_cols' => array('min', 'max', 'average'));
 }
Ejemplo n.º 7
0
 /**
  * Creates a formatted array of all Benchmarks
  *
  * @return array formatted benchmarks
  */
 public static function get_benchmarks()
 {
     if (Kohana::$profiling == FALSE) {
         return array();
     }
     if (self::$_benchmarks !== FALSE) {
         return self::$_benchmarks;
     }
     $groups = Profiler::groups();
     $result = array();
     foreach (array_keys($groups) as $group) {
         if (strpos($group, 'database (') === FALSE) {
             foreach ($groups[$group] as $name => $marks) {
                 $stats = Profiler::stats($marks);
                 $result[$group][] = array('name' => $name, 'count' => count($marks), 'total_time' => $stats['total']['time'], 'avg_time' => $stats['average']['time'], 'total_memory' => $stats['total']['memory'], 'avg_memory' => $stats['average']['memory']);
             }
         }
     }
     // add total stats
     $total = Profiler::application();
     $result['application'] = array('count' => 1, 'total_time' => $total['current']['time'], 'avg_time' => $total['average']['time'], 'total_memory' => $total['current']['memory'], 'avg_memory' => $total['average']['memory']);
     self::$_benchmarks = $result;
     return $result;
 }
 public function after()
 {
     if (Kohana::$profiling === TRUE) {
         xml::to_XML(array('benchmark' => Profiler::application()), $this->xml_meta);
     }
     if ($this->auto_render == TRUE) {
         // Render the template immediately after the controller method
         $this->render();
     }
 }
Ejemplo n.º 9
0
</th>
                <th class="profiler_min"><?php 
echo __('runtime');
?>
</th>
                <th class="profiler_max"><?php 
echo __('memory');
?>
</th>
                <th class="profiler_total"><?php 
echo __('include file');
?>
</th>
            </tr>
        <?php 
foreach (array('Core Execution' => Profiler::core_system(), 'Application Execution' => Profiler::application()) as $key => $stats) {
    ?>
            <tr class="profiler_mark profiler_time">
                <th class="profiler_name" style="padding: 8px 6px;"><?php 
    echo __($key);
    ?>
</th>
                <td class="profiler_min">
                <?php 
    echo number_format($stats['max']['time'], 6), ' ', __('seconds');
    ?>
                </td>
                <td class="profiler_max">
                <?php 
    echo number_format($stats['max']['memory'] / 1024, 4), ' kb';
    ?>
Ejemplo n.º 10
0
 /**
  * Get application benchmark
  *
  * <code>
  * Debugger::get_benchmark_application()
  * </code>
  *
  * @static
  * @return StdClass
  */
 public static function get_benchmark_application()
 {
     if (Debugger::$_benchmark_application !== null) {
         return Debugger::$_benchmark_application;
     }
     $benchmark_application = new StdClass();
     $profiler_application = Profiler::application();
     $benchmark_application->min = $profiler_application['min'];
     $benchmark_application->max = $profiler_application['max'];
     $benchmark_application->total = $profiler_application['total'];
     $benchmark_application->average = $profiler_application['average'];
     $benchmark_application->current = $profiler_application['current'];
     return Debugger::$_benchmark_application = $benchmark_application;
 }
Ejemplo n.º 11
0
 public function benchmark($table = FALSE)
 {
     if ($this->enabled) {
         foreach (Profiler::groups() as $group => $benchmarks) {
             $tablename = ucfirst($group);
             // Exclude database unless specifically run
             if (empty($table) and strpos($tablename, 'Database') === FALSE or strpos($tablename, $table) === 0) {
                 $row = array(array(__('Benchmark'), __('Min'), __('Max'), __('Average'), __('Total')));
                 foreach ($benchmarks as $name => $tokens) {
                     $stats = Profiler::stats($tokens);
                     $cell = array($name . ' (' . count($tokens) . ')');
                     foreach (array('min', 'max', 'average', 'total') as $key) {
                         $cell[] = ' ' . number_format($stats[$key]['time'], 6) . ' ' . __('seconds');
                     }
                     $row[] = $cell;
                 }
                 $cell = array('');
                 foreach (array('min', 'max', 'average', 'total') as $key) {
                     $cell[] = ' ' . number_format($stats[$key]['memory'] / 1024, 4) . ' kb';
                 }
                 $row[] = $cell;
                 // Translate before passing...
                 $this->fb(array(__($tablename), $row), FirePHP::TABLE);
             }
         }
         if (empty($table) || strpos('Application', $table) === 0) {
             $stats = Profiler::application();
             $tablename = array(__('Application Execution') . ' (' . $stats['count'] . ')');
             $row = array(array('', 'min', 'max', 'average', 'current'));
             $cell = array('Time');
             foreach (array('min', 'max', 'average', 'current') as $key) {
                 $cell[] = number_format($stats[$key]['time'], 6) . ' ' . __('seconds');
             }
             $row[] = $cell;
             $cell = array('Memory');
             foreach (array('min', 'max', 'average', 'current') as $key) {
                 $cell[] = number_format($stats[$key]['memory'] / 1024, 4) . ' kb';
             }
             $row[] = $cell;
             $this->fb(array($tablename, $row), FirePHP::TABLE);
         }
     }
     return $this;
 }