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


PHP Benchmark::get方法代码示例

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


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

示例1: benchmarks

 /**
  * Database query benchmarks.
  *
  * @return  void
  */
 public function benchmarks()
 {
     $benchmarks = Benchmark::get(TRUE);
     // Moves the first benchmark (total execution time) to the end of the array
     $benchmarks = array_slice($benchmarks, 1) + array_slice($benchmarks, 0, 1);
     $table = array();
     $table[] = array('Benchmark', 'Time', 'Memory');
     foreach ($benchmarks as $name => $benchmark) {
         // Clean unique id from system benchmark names
         $name = ucwords(str_replace(array('_', '-'), ' ', str_replace(SYSTEM_BENCHMARK . '_', '', $name)));
         $table[] = array($name, number_format($benchmark['time'], 3), number_format($benchmark['memory'] / 1024 / 1024, 2) . 'MB');
     }
     $this->firephp->fb(array(count($benchmarks) . ' benchmarks took ' . number_format($benchmark['time'], 3) . ' seconds and used up ' . number_format($benchmark['memory'] / 1024 / 1024, 2) . 'MB' . ' memory', $table), FirePHP::TABLE);
 }
开发者ID:NaszvadiG,项目名称:codeigniter-debug-toolbar,代码行数:19,代码来源:Fire_Profiler.php

示例2: render

 /**
  * Inserts global Kohana variables into the generated output and prints it.
  *
  * @param   string  final output that will displayed
  * @return  void
  */
 public static function render($output)
 {
     // Fetch memory usage in MB
     $memory = function_exists('memory_get_usage') ? memory_get_usage() / 1024 / 1024 : 0;
     // Fetch benchmark for page execution time
     $benchmark = Benchmark::get(SYSTEM_BENCHMARK . '_total_execution');
     if (self::config('core.render_stats') === TRUE) {
         // Replace the global template variables
         $output = str_replace(array('{kohana_version}', '{kohana_codename}', '{execution_time}', '{memory_usage}', '{included_files}'), array(KOHANA_VERSION, KOHANA_CODENAME, $benchmark['time'], number_format($memory, 2) . 'MB', count(get_included_files())), $output);
     }
     if ($level = self::config('core.output_compression') and ini_get('output_handler') !== 'ob_gzhandler' and (int) ini_get('zlib.output_compression') === 0) {
         if ($level < 1 or $level > 9) {
             // Normalize the level to be an integer between 1 and 9. This
             // step must be done to prevent gzencode from triggering an error
             $level = max(1, min($level, 9));
         }
         if (stripos(@$_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) {
             $compress = 'gzip';
         } elseif (stripos(@$_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate') !== FALSE) {
             $compress = 'deflate';
         }
     }
     if (isset($compress) and $level > 0) {
         switch ($compress) {
             case 'gzip':
                 // Compress output using gzip
                 $output = gzencode($output, $level);
                 break;
             case 'deflate':
                 // Compress output using zlib (HTTP deflate)
                 $output = gzdeflate($output, $level);
                 break;
         }
         // This header must be sent with compressed content to prevent
         // browser caches from breaking
         header('Vary: Accept-Encoding');
         // Send the content encoding header
         header('Content-Encoding: ' . $compress);
         // Sending Content-Length in CGI can result in unexpected behavior
         if (stripos(PHP_SAPI, 'cgi') === FALSE) {
             header('Content-Length: ' . strlen($output));
         }
     }
     echo $output;
 }
开发者ID:nanangsyaifudin,项目名称:HAC-2012,代码行数:51,代码来源:Kohana.php

示例3: save_results

 /**
  * Saves the benchmark results to a database
  * @todo Use the database libraries for this instead of platform-specific DB calls
  *
  * @return void
  */
 public static function save_results()
 {
     // Ignore all of these actions if we have benchmarking disabled
     if (Kohana::config('benchmark.enable') === FALSE) {
         return FALSE;
     }
     // Connect to the benchmark database
     $db = Kohana::config('benchmark.db');
     $link = mysql_connect($db['host'], $db['user'], $db['pass']) or die('Could not connect to benchmark database.');
     mysql_select_db($db['database']) or die('Could not select benchmark database.');
     $table = mysql_real_escape_string($db['table_prefix']) . 'benchmark';
     $benchmark_results = Benchmark::get(TRUE);
     foreach ($benchmark_results as $name => $data) {
         // Don't save the generic system benchmark results
         if (strstr($name, 'system_benchmark_') === FALSE) {
             $query = 'INSERT INTO ' . $table . ' (`name`, `time`, `memory`) VALUES (\'' . mysql_real_escape_string($name) . '\', \'' . mysql_real_escape_string($data['time']) . '\', \'' . mysql_real_escape_string($data['memory']) . '\');';
             // Execute the query
             mysql_query($query, $link);
         }
     }
     // Close the connection to the Benchmar DB
     mysql_close($link);
 }
开发者ID:Dirichi,项目名称:Ushahidi_Web,代码行数:29,代码来源:Benchmark.php

示例4: benchmarks

 /**
  * Benchmark times and memory usage from the Benchmark library.
  *
  * @return  void
  */
 public function benchmarks()
 {
     if (!($table = $this->table('benchmarks'))) {
         return;
     }
     $table->add_column();
     $table->add_column('kp-column kp-data');
     $table->add_column('kp-column kp-data');
     $table->add_row(array('Benchmarks', 'Time', 'Memory'), 'kp-title', 'background-color: #FFE0E0');
     $benchmarks = Benchmark::get(TRUE);
     // Moves the first benchmark (total execution time) to the end of the array
     $benchmarks = array_slice($benchmarks, 1) + array_slice($benchmarks, 0, 1);
     text::alternate();
     foreach ($benchmarks as $name => $benchmark) {
         // Clean unique id from system benchmark names
         $name = ucwords(str_replace(array('_', '-'), ' ', str_replace(SYSTEM_BENCHMARK . '_', '', $name)));
         $data = array($name, number_format($benchmark['time'], 3), number_format($benchmark['memory'] / 1024 / 1024, 2) . 'MB');
         $class = text::alternate('', 'kp-altrow');
         if ($name == 'Total Execution') {
             $class = 'kp-totalrow';
         }
         $table->add_row($data, $class);
     }
 }
开发者ID:nebogeo,项目名称:borrowed-scenery,代码行数:29,代码来源:Profiler.php

示例5: benchmarks

 /**
  * Benchmark times and memory usage from the Benchmark library.
  *
  * @return  void
  */
 public static function benchmarks()
 {
     if (!Profiler::show('benchmarks')) {
         return;
     }
     $table = new Profiler_Table();
     $table->add_column();
     $table->add_column('kp-column kp-data');
     $table->add_column('kp-column kp-data');
     $table->add_column('kp-column kp-data');
     $table->add_row(array(__('Benchmarks'), __('Count'), __('Time'), __('Memory')), 'kp-title', 'background-color: #FFE0E0');
     $benchmarks = Benchmark::get(TRUE);
     // Moves the first benchmark (total execution time) to the end of the array
     $benchmarks = array_slice($benchmarks, 1) + array_slice($benchmarks, 0, 1);
     text::alternate();
     foreach ($benchmarks as $name => $benchmark) {
         // Clean unique id from system benchmark names
         $name = ucwords(str_replace(array('_', '-'), ' ', str_replace(SYSTEM_BENCHMARK . '_', '', $name)));
         $data = array(__($name), $benchmark['count'], number_format($benchmark['time'], Kohana::config('profiler.time_decimals')), number_format($benchmark['memory'] / 1024 / 1024, Kohana::config('profiler.memory_decimals')) . 'MB');
         $class = text::alternate('', 'kp-altrow');
         if ($name == 'Total Execution') {
             // Clear the count column
             $data[1] = '';
             $class = 'kp-totalrow';
         }
         $table->add_row($data, $class);
     }
     Profiler::add($table);
 }
开发者ID:bluelovers,项目名称:Kohana-Clone,代码行数:34,代码来源:Profiler.php

示例6: parse_css

 /**
  * Parse the CSS
  *
  * @return string - The processes css file as a string
  * @author Anthony Short
  **/
 public static function parse_css()
 {
     # If the cache is stale or doesn't exist
     if (self::config('core.cache.mod_time') <= self::config('core.request.mod_time')) {
         # Start the timer
         Benchmark::start("parse_css");
         # Compress it before parsing
         CSS::compress(CSS::$css);
         # Import CSS files
         Import::parse();
         if (self::config('core.auto_include_mixins') === true) {
             # Import the mixins in the plugin/module folders
             Mixins::import_mixins('framework/mixins');
         }
         # Parse our css through the plugins
         foreach (self::$plugins as $plugin) {
             call_user_func(array($plugin, 'import_process'));
         }
         # Compress it before parsing
         CSS::compress(CSS::$css);
         # Parse the constants
         Constants::parse();
         foreach (self::$plugins as $plugin) {
             call_user_func(array($plugin, 'pre_process'));
         }
         # Parse the @grid
         Layout::parse_grid();
         # Replace the constants
         Constants::replace();
         # Parse @for loops
         Iteration::parse();
         foreach (self::$plugins as $plugin) {
             call_user_func(array($plugin, 'process'));
         }
         # Compress it before parsing
         CSS::compress(CSS::$css);
         # Parse the mixins
         Mixins::parse();
         # Find missing constants
         Constants::replace();
         # Compress it before parsing
         CSS::compress(CSS::$css);
         foreach (self::$plugins as $plugin) {
             call_user_func(array($plugin, 'post_process'));
         }
         # Parse the expressions
         Expression::parse();
         # Parse the nested selectors
         NestedSelectors::parse();
         # Convert all url()'s to absolute paths if required
         if (self::config('core.absolute_urls') === true) {
             CSS::convert_to_absolute_urls();
         }
         # Replaces url()'s that start with ~ to lead to the CSS directory
         CSS::replace_css_urls();
         # Add the extra string we've been storing
         CSS::$css .= CSS::$append;
         # If they want to minify it
         if (self::config('core.minify_css') === true) {
             Minify::compress();
         } else {
             CSS::pretty();
         }
         # Formatting hook
         foreach (self::$plugins as $plugin) {
             call_user_func(array($plugin, 'formatting_process'));
         }
         # Validate the CSS
         if (self::config('core.validate') === true) {
             Validate::check();
         }
         # Stop the timer...
         Benchmark::stop("parse_css");
         if (self::config('core.show_header') === TRUE) {
             CSS::$css = "/* Processed by CSScaffold on " . gmdate('r') . " in " . Benchmark::get("parse_css", "time") . " seconds */\n\n" . CSS::$css;
         }
         # Write the css file to the cache
         self::cache_write(CSS::$css);
         # Output process hook for plugins to display views.
         # Doesn't run in production mode.
         if (!IN_PRODUCTION) {
             foreach (array_merge(self::$plugins, self::$modules) as $plugin) {
                 call_user_func(array($plugin, 'output'));
             }
         }
     }
 }
开发者ID:Keukendeur,项目名称:csscaffold,代码行数:93,代码来源:CSScaffold.php

示例7: benchmarks

 public static function benchmarks()
 {
     $benchmarks = array();
     foreach (Benchmark::get(true) as $name => $benchmark) {
         $benchmarks[$name] = array('name' => ucwords(str_replace(array('_', '-'), ' ', str_replace(SYSTEM_BENCHMARK . '_', '', $name))), 'time' => $benchmark['time'], 'memory' => $benchmark['memory']);
     }
     $benchmarks = array_slice($benchmarks, 1) + array_slice($benchmarks, 0, 1);
     return $benchmarks;
 }
开发者ID:bicho44,项目名称:imglistados,代码行数:9,代码来源:DebugToolbar.php

示例8: mt_rand

    for ($i = 0; $i < 5000; $i++) {
        $r = mt_rand(0, 2);
        $db->query(sprintf($sql, $records[$r]->title, $records[$r]->contents));
    }
}
if (isset($_SERVER['argv'][1]) and $_SERVER['argv'][1] == 'fill') {
    echo 'Generating test data.' . PHP_EOL;
    for ($i = 0; $i < 10; $i++) {
        fill_db();
        echo ($i + 1) * 5000 . ' records generated.' . PHP_EOL;
    }
    exit;
}
Benchmark::start('select records');
$records = $db->query('SELECT id, title, contents FROM posts')->fetchAll(PDO::FETCH_OBJ);
Benchmark::stop('select records');
Benchmark::start('index');
$data = array('title' => 'Craiglist ads', 'records' => $records);
$index = parse('index.tpl', $data);
create('index', $index);
Benchmark::stop('index');
Benchmark::start('pages');
foreach ($records as $page) {
    $data = array('page' => $page);
    $content = parse('page.tpl', $data);
    create($page->id, $content);
}
Benchmark::stop('pages');
Benchmark::stop('page');
var_dump(Benchmark::get(TRUE));
开发者ID:bgads,项目名称:adsbg,代码行数:30,代码来源:t.php

示例9: partials

 public function partials()
 {
     $data = $this->templateData();
     Benchmark::start('grid');
     $grid = DataGrid_Factory::create('test');
     $grid->table->border = 1;
     for ($column = 1; $column <= count($data['head']); $column++) {
         $grid->addField('key' . $column, 'Header ' . $column);
     }
     $grid->addColumn('static data', 'Static Head');
     $template = $grid->render('partials');
     $this->view->template = $template['template'];
     Benchmark::stop('grid');
     $benchmark = Benchmark::get('grid');
     $this->view->time = $benchmark['time'];
     $this->view->partials = json_encode($template['partials']);
     $this->view->data = json_encode($this->templateData());
 }
开发者ID:swk,项目名称:bluebox,代码行数:18,代码来源:datagrid.php


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