当前位置: 首页>>代码示例>>PHP>>正文


PHP Profiler::stats方法代码示例

本文整理汇总了PHP中Profiler::stats方法的典型用法代码示例。如果您正苦于以下问题:PHP Profiler::stats方法的具体用法?PHP Profiler::stats怎么用?PHP Profiler::stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Profiler的用法示例。


在下文中一共展示了Profiler::stats方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: smarty_function_Kohana_profile

/**
 * 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);
}
开发者ID:pg7812,项目名称:kohana-module-smarty,代码行数:28,代码来源:function.Kohana_profile.php

示例2: group_stats

 /**
  * Gets the min, max, average and total of profiler groups as an array.
  *
  *     $stats = Profiler::group_stats('test');
  *
  * @param   mixed   $groups single group name string, or array with group names; all groups by default
  * @return  array   min, max, average, total
  * @uses    Profiler::groups
  * @uses    Profiler::stats
  */
 public static function group_stats($groups = NULL)
 {
     // Which groups do we need to calculate stats for?
     $groups = $groups === NULL ? Profiler::groups() : array_intersect_key(Profiler::groups(), array_flip((array) $groups));
     // All statistics
     $stats = array();
     foreach ($groups as $group => $names) {
         foreach ($names as $name => $tokens) {
             // Store the stats for each subgroup.
             // We only need the values for "total".
             $_stats = Profiler::stats($tokens);
             $stats[$group][$name] = $_stats['total'];
         }
     }
     // Group stats
     $groups = array();
     foreach ($stats as $group => $names) {
         // Min and max are unknown by default
         $groups[$group]['min'] = $groups[$group]['max'] = array('time' => NULL, 'memory' => NULL);
         // Total values are always integers
         $groups[$group]['total'] = array('time' => 0, 'memory' => 0);
         foreach ($names as $total) {
             if (!isset($groups[$group]['min']['time']) or $groups[$group]['min']['time'] > $total['time']) {
                 // Set the minimum time
                 $groups[$group]['min']['time'] = $total['time'];
             }
             if (!isset($groups[$group]['min']['memory']) or $groups[$group]['min']['memory'] > $total['memory']) {
                 // Set the minimum memory
                 $groups[$group]['min']['memory'] = $total['memory'];
             }
             if (!isset($groups[$group]['max']['time']) or $groups[$group]['max']['time'] < $total['time']) {
                 // Set the maximum time
                 $groups[$group]['max']['time'] = $total['time'];
             }
             if (!isset($groups[$group]['max']['memory']) or $groups[$group]['max']['memory'] < $total['memory']) {
                 // Set the maximum memory
                 $groups[$group]['max']['memory'] = $total['memory'];
             }
             // Increase the total time and memory
             $groups[$group]['total']['time'] += $total['time'];
             $groups[$group]['total']['memory'] += $total['memory'];
         }
         // Determine the number of names (subgroups)
         $count = count($names);
         // Determine the averages
         $groups[$group]['average']['time'] = $groups[$group]['total']['time'] / $count;
         $groups[$group]['average']['memory'] = $groups[$group]['total']['memory'] / $count;
     }
     return $groups;
 }
开发者ID:noikiy,项目名称:kohana,代码行数:60,代码来源:Profiler.php

示例3: __

        echo $key;
        ?>
"><?php 
        echo __(ucfirst($key));
        ?>
</th>
			<?php 
    }
    ?>
		</tr>
		<?php 
    foreach ($benchmarks as $name => $tokens) {
        ?>
		<tr class="mark time">
			<?php 
        $stats = Profiler::stats($tokens);
        ?>
			<th class="name" rowspan="2" scope="rowgroup"><?php 
        echo HTML::chars($name), ' (', count($tokens), ')';
        ?>
</th>
			<?php 
        foreach ($group_cols as $key) {
            ?>
			<td class="<?php 
            echo $key;
            ?>
">
				<div>
					<div class="value"><?php 
            echo number_format($stats[$key]['time'], 6);
开发者ID:noikiy,项目名称:kohana,代码行数:31,代码来源:stats.php

示例4: core_system

 /**
  * 返回框架调用信息
  *
  * @return array
  */
 public static function core_system()
 {
     $groups = self::groups();
     $token = $groups['Core']['PHP Framework Start'];
     $rs = Profiler::stats($token);
     $rs['file_count'] = Profiler::$_marks[$token[0]]['file_count'];
     return $rs;
 }
开发者ID:xiaodin1,项目名称:myqee,代码行数:13,代码来源:profiler.class.php

示例5: getSql

 /**
  * @return array|int|string
  */
 private static function getSql()
 {
     // calc explain
     if (self::cfg('html.showSqlExplain') && self::cfg('html.showSqlExplain')) {
         /*Перебераем все вкладки*/
         foreach (self::$_SQL as $instance => $query) {
             /**/
             foreach ($query as $sql => $data) {
                 if (stripos($sql, 'select') === 0) {
                     if (class_exists('\\Database\\ActiveRecord\\Record')) {
                         $pdo = \Database\ActiveRecord\Record::$db->getPdoInstance();
                         try {
                             /*
                             								$stmt = $pdo->prepare('EXPLAIN '.$sql);
                             								//$stmt->execute();
                             								$expl = $stmt->fetchAll(PDO::FETCH_ASSOC);*/
                         } catch (PDOException $e) {
                             self::addData($e, 'PDOException');
                         }
                     } else {
                         $expl = Database::instance($instance)->query(Database::SELECT, 'EXPLAIN ' . $sql)->as_array();
                     }
                     self::$_SQL[$instance][$sql]['explain'] = $expl;
                 }
             }
         }
     }
     // collect data
     $sql = [];
     $groups = Profiler::groups();
     foreach ($groups as $groupName => $benchmarks) {
         if (strpos($groupName, 'database') !== 0) {
             continue;
         }
         $sqlGroup = preg_replace('/(.*) \\(\'(.*)\'\\)/Usi', '$2', $groupName);
         /*$sqlGroup = substr($groupName, strpos($groupName, '(') + 2,
         				strpos($groupName, ')') - strpos($groupName, '(') - 2);
         */
         $sql[$sqlGroup] = ['data' => [], 'total' => ['time' => 0, 'memory' => 0, 'count' => 0]];
         foreach ($benchmarks as $benchName => $tokens) {
             foreach ($tokens as $token) {
                 $stats = Profiler::stats([$token]);
                 $sql_string = $benchName;
                 if (isset(self::$_SQL[$sqlGroup][$benchName]['data'])) {
                     if (strpos($sql_string, ":")) {
                         foreach (self::$_SQL[$sqlGroup][$benchName]['data'] as $key => $value) {
                             $sql_string = preg_replace('|' . $key . '|Usi', "'" . $value . "'", $sql_string);
                         }
                     }
                 }
                 $sql[$sqlGroup]['data'][] = ['sql' => $sql_string, 'time' => $stats['total']['time'], 'memory' => $stats['total']['memory'], 'rows' => isset(self::$_SQL[$sqlGroup][$benchName]) ? self::$_SQL[$sqlGroup][$benchName]['rows'] : null, 'explain' => isset(self::$_SQL[$sqlGroup][$benchName]) ? self::$_SQL[$sqlGroup][$benchName]['explain'] : null];
                 $sql[$sqlGroup]['total']['time'] += $stats['total']['time'];
                 $sql[$sqlGroup]['total']['memory'] += $stats['total']['memory'];
                 $sql[$sqlGroup]['total']['count']++;
             }
         }
     }
     return $sql;
 }
开发者ID:astar3086,项目名称:studio_logistic,代码行数:62,代码来源:ProfilerToolbar.php

示例6: get_benchmarks

 /**
  * 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;
 }
开发者ID:bosoy83,项目名称:progtest,代码行数:29,代码来源:debugtoolbar.php

示例7: getSql

 private static function getSql()
 {
     // calc explain
     if (self::cfg('html.showSqlExplain') && self::cfg('html.showSqlExplain')) {
         foreach (self::$_SQL as $instance => $query) {
             foreach ($query as $sql => $data) {
                 if (stripos($sql, 'select') === 0) {
                     $explain = Database::instance($instance)->query(Database::SELECT, 'EXPLAIN ' . $sql)->as_array();
                     self::$_SQL[$instance][$sql]['explain'] = $explain;
                 }
             }
         }
     }
     // collect data
     $sql = array();
     $groups = Profiler::groups();
     foreach ($groups as $groupName => $benchmarks) {
         if (strpos($groupName, 'database') !== 0) {
             continue;
         }
         $sqlGroup = substr($groupName, strpos($groupName, '(') + 1, strpos($groupName, ')') - strpos($groupName, '(') - 1);
         $sql[$sqlGroup] = array('data' => array(), 'total' => array('time' => 0, 'memory' => 0, 'count' => 0));
         foreach ($benchmarks as $benchName => $tokens) {
             // skip explain queries
             if (stripos(trim($benchName), 'explain') === 0) {
                 continue;
             }
             foreach ($tokens as $token) {
                 $stats = Profiler::stats(array($token));
                 $sql[$sqlGroup]['data'][] = array('sql' => $benchName, 'time' => $stats['total']['time'], 'memory' => $stats['total']['memory'], 'rows' => isset(self::$_SQL[$sqlGroup][$benchName]) ? self::$_SQL[$sqlGroup][$benchName]['rows'] : null, 'explain' => isset(self::$_SQL[$sqlGroup][$benchName]) ? self::$_SQL[$sqlGroup][$benchName]['explain'] : null);
                 $sql[$sqlGroup]['total']['time'] += $stats['total']['time'];
                 $sql[$sqlGroup]['total']['memory'] += $stats['total']['memory'];
                 $sql[$sqlGroup]['total']['count']++;
             }
         }
     }
     return $sql;
 }
开发者ID:tscms,项目名称:profilertoolbar,代码行数:38,代码来源:ProfilerToolbar.php

示例8: group_stats

 /**
  * 返回分组对应的性能统计数据
  *
  * @param string $groups        	
  * @return array [min, max, average, total]
  * @uses Profiler::groups
  * @uses Profiler::stats
  * @example $stats = Profiler::group_stats('resize');
  */
 public static function group_stats($groups = NULL)
 {
     $groups = $groups === NULL ? Profiler::groups() : array_intersect_key(Profiler::groups(), array_flip((array) $groups));
     $stats = array();
     foreach ($groups as $group => $names) {
         foreach ($names as $name => $tokens) {
             $_stats = Profiler::stats($tokens);
             $stats[$group][$name] = $_stats['total'];
         }
     }
     $groups = array();
     foreach ($stats as $group => $names) {
         $groups[$group]['min'] = $groups[$group]['max'] = array('time' => NULL, 'memory' => NULL);
         $groups[$group]['total'] = array('time' => 0, 'memory' => 0);
         foreach ($names as $total) {
             if (!isset($groups[$group]['min']['time']) or $groups[$group]['min']['time'] > $total['time']) {
                 $groups[$group]['min']['time'] = $total['time'];
             }
             if (!isset($groups[$group]['min']['memory']) or $groups[$group]['min']['memory'] > $total['memory']) {
                 $groups[$group]['min']['memory'] = $total['memory'];
             }
             if (!isset($groups[$group]['max']['time']) or $groups[$group]['max']['time'] < $total['time']) {
                 $groups[$group]['max']['time'] = $total['time'];
             }
             if (!isset($groups[$group]['max']['memory']) or $groups[$group]['max']['memory'] < $total['memory']) {
                 $groups[$group]['max']['memory'] = $total['memory'];
             }
             $groups[$group]['total']['time'] += $total['time'];
             $groups[$group]['total']['memory'] += $total['memory'];
         }
         $count = count($names);
         $groups[$group]['average']['time'] = $groups[$group]['total']['time'] / $count;
         $groups[$group]['average']['memory'] = $groups[$group]['total']['memory'] / $count;
     }
     return $groups;
 }
开发者ID:amlun,项目名称:phptools,代码行数:45,代码来源:Profiler.php

示例9: get_benchmark_groups

 /**
  * Get benchmark groups
  *
  * <code>
  * Debugger::get_benchmark_groups()
  * </code>
  *
  * @return array formatted benchmarks
  */
 public static function get_benchmark_groups()
 {
     if (Kohana::$profiling === false) {
         return array();
     }
     if (empty(Debugger::$_benchmark_groups) === false) {
         return Debugger::$_benchmark_groups;
     }
     $groups = Profiler::groups();
     $result = array();
     foreach (array_keys($groups) as $group) {
         if (strpos($group, 'database (') === false) {
             foreach ($groups[$group] as $name => $marks) {
                 $result[$group][] = array('name' => $name, 'count' => count($marks), 'stats' => Profiler::stats($marks));
             }
         }
     }
     return $result;
 }
开发者ID:nexeck,项目名称:kohana-debugger,代码行数:28,代码来源:debugger.php

示例10: benchmark

 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;
 }
开发者ID:hkilter,项目名称:OpenSupplyChains,代码行数:44,代码来源:firephp.php


注:本文中的Profiler::stats方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。