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


PHP Benchmark::start方法代码示例

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


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

示例1: render

 public static function render($print = false)
 {
     Benchmark::start(self::$benchmark_name);
     $template = new View('toolbar');
     if (Kohana::config('debug_toolbar.panels.database')) {
         $template->set('queries', self::queries());
     }
     if (Kohana::config('debug_toolbar.panels.logs')) {
         $template->set('logs', self::logs());
     }
     if (Kohana::config('debug_toolbar.panels.vars_and_config')) {
         $template->set('configs', self::configs());
     }
     if (Kohana::config('debug_toolbar.panels.files')) {
         $template->set('files', self::files());
     }
     if (Kohana::config('debug_toolbar.firephp_enabled')) {
         self::firephp();
     }
     switch (Kohana::config('debug_toolbar.align')) {
         case 'right':
         case 'center':
         case 'left':
             $template->set('align', Kohana::config('debug_toolbar.align'));
             break;
         default:
             $template->set('align', 'left');
     }
     $template->set('scripts', file_get_contents(Kohana::find_file('views', 'toolbar', true, 'js')));
     Benchmark::stop(self::$benchmark_name);
     if (Kohana::config('debug_toolbar.panels.benchmarks')) {
         $template->set('benchmarks', self::benchmarks());
     }
     if (Event::$data) {
         if (Kohana::config('debug_toolbar.auto_render') or Kohana::config('debug_toolbar.secret_key') !== FALSE and isset($_GET[Kohana::config('debug_toolbar.secret_key')])) {
             // try to add css to <head>, otherwise, send to template
             $styles = file_get_contents(Kohana::find_file('views', 'toolbar', false, 'css'));
             if (stripos(Event::$data, '</head>') !== FALSE) {
                 Event::$data = str_ireplace('</head>', $styles . '</head>', Event::$data);
             } else {
                 $template->set('styles', $styles);
             }
             // try to add js and HTML just before the </body> tag,
             // otherwise just append it to the output
             if (stripos(Event::$data, '</body>') !== FALSE) {
                 Event::$data = str_ireplace('</body>', $template->render() . '</body>', Event::$data);
             } else {
                 Event::$data .= $template->render();
             }
         }
     } else {
         if ($print) {
             $template->render(TRUE);
         } else {
             return $template->render();
         }
     }
 }
开发者ID:bicho44,项目名称:imglistados,代码行数:58,代码来源:DebugToolbar.php

示例2: execute

 public function execute($input_parameters = null)
 {
     try {
         $this->benchmark->start();
         return parent::execute($input_parameters);
     } finally {
         $this->benchmark->end();
     }
 }
开发者ID:vincent4vx,项目名称:SimpleFramework,代码行数:9,代码来源:Database.php

示例3: testBenchmarkObjectMethod

 public function testBenchmarkObjectMethod()
 {
     Benchmark::__reset();
     $b = Benchmark::start($this, __METHOD__);
     $this->assertEqual($b->get_benchmark_class(), "TestBenchmark", "La classe del benchmark non corrisponde");
     $this->assertEqual($b->get_benchmark_method(), "testBenchmarkObjectMethod", "Il metodo del benchmark non corrisponde");
     $this->assertEqual($b->get_benchmark_signature(), "TestBenchmark@testBenchmarkObjectMethod");
     $this->assertFalse($b->is_finished(), "Il benchmark risulta terminato!");
     Benchmark::stop();
     $this->assertTrue($b->is_finished(), "Il benchmark non risulta terminato!");
 }
开发者ID:mbcraft,项目名称:frozen,代码行数:11,代码来源:benchmark_test.php

示例4: add_as_author_of

 public function add_as_author_of(User_Model $author, ORM $object)
 {
     if ($this->is_possible_to_add_authors_to($object)) {
         Benchmark::start('add_as_author_of');
         try {
             $database = new Database();
             $database->from('workshop_data');
             $database->set(array('object_name' => $object->object_name, 'user_id' => $author->id, 'object_id' => $object->id));
             $database->insert();
         } catch (Kohana_Database_Exception $e) {
             if (strstr($e->getMessage(), 'Duplicate entry')) {
                 throw new Workshop_Duplicate_Author_Exception($author, $object);
             } else {
                 throw $e;
             }
         }
         Benchmark::stop('add_as_author_of');
     } else {
         throw new Workshop_Max_Limit_Exception($object, $this->get_number_of_authors_of($object), 1, $this->config_delegate->max_authors_for($object));
     }
 }
开发者ID:vitrinephp,项目名称:Vitrine-PHP,代码行数:21,代码来源:Workshop.php

示例5: define

        }
    }
}
// Set default controller and action
define('DEFAULT_CONTROLLER', $route['_default']);
define('DEFAULT_ACTION', 'index');
// Load core files
require SYSPATH . '/core/Model' . EXT;
require SYSPATH . '/core/View' . EXT;
require SYSPATH . '/core/Controller' . EXT;
require SYSPATH . '/helpers/Inflector' . EXT;
require SYSPATH . '/core/Benchmark' . EXT;
require SYSPATH . '/core/Observer' . EXT;
require SYSPATH . '/core/Autoloader' . EXT;
require SYSPATH . '/core/Simplengine' . EXT;
Benchmark::start('total');
// Set view suffix
define('VIEW_SUFFIX', $config['view_suffix']);
// Set base url
define('BASE_URL', $config['base_url']);
if (isset($config[$db_group]['host'])) {
    // Database setup
    define('DB_DSN', $db_driver . ':dbname=' . $config[$db_group]['database'] . ';host=' . $config[$db_group]['host']);
    define('DB_USER', $config[$db_group]['username']);
    define('DB_PASS', $config[$db_group]['password']);
    define('TABLE_PREFIX', $config[$db_group]['prefix']);
    define('USE_PDO', $config[$db_group]['pdo']);
    if (USE_PDO) {
        try {
            $__SE_CONN__ = new PDO(DB_DSN, DB_USER, DB_PASS);
        } catch (PDOException $error) {
开发者ID:silentworks,项目名称:the-compressor,代码行数:31,代码来源:Bootstrap.php

示例6: echo_formatted_data

 private function echo_formatted_data($data, $datatype)
 {
     Benchmark::start('echo_formatted_data');
     switch (strtolower($datatype)) {
         case 'json':
             header('Content-type: application/json');
             $json = json_encode($data);
             $callback = $this->input->get('jsonp_callback');
             if ($callback) {
                 echo $callback . '(' . $json . ');';
             } else {
                 echo $json;
             }
             break;
         case 'xml':
             header('Content-type: application/xml');
             $xml = '<?xml version="1.0" encoding="UTF-8"?><result></result>';
             $xml = simplexml_load_string($xml);
             $this->create_xml_object($xml, $data);
             $dom = new DOMDocument('1.0');
             $dom->preserveWhiteSpace = false;
             $dom->formatOutput = true;
             $dom->loadXML($xml->asXML());
             echo $dom->saveXML();
             break;
         case 'csv':
             header('Content-type: text/csv');
             $outstream = fopen("php://output", 'w');
             if (!isset($data[0])) {
                 $data = current($data);
             }
             $firstElm = current($data);
             if (!isset($firstElm[0])) {
                 fputcsv($outstream, array_keys(get_object_vars(current(current($data)))), ',', '"');
             } else {
                 fputcsv($outstream, array_keys(get_object_vars(current($data))), ',', '"');
             }
             function __outputCSV(&$vals, $key, $filehandler)
             {
                 if (!isset($vals[0])) {
                     fputcsv($filehandler, get_object_vars(current($vals)), ',', '"');
                 } else {
                     fputcsv($filehandler, get_object_vars($vals), ',', '"');
                 }
             }
             array_walk($data, '__outputCSV', $outstream);
             fclose($outstream);
             break;
         default:
             throw new Kohana_404_Exception();
             break;
     }
     Benchmark::stop('echo_formatted_data');
 }
开发者ID:jverkoey,项目名称:uwdata.ca,代码行数:54,代码来源:v1.php

示例7: initialize

 /**
  * Initializes all necessary FLOWLite objects 
  *
  * @see run()
  */
 public function initialize()
 {
     $this->initializeApplication();
     $this->initializeSystem();
     $this->initializeClassLoader();
     $this->initializeFrameworkNamespace();
     Benchmark::start('SYS');
     $this->initializeExceptions();
     $this->initializeErrorHandling();
     $this->initializeObjectManager();
     $this->initializeConfiguration();
     $this->initializeRegistry();
     $this->initializeSession();
     $this->initializeProtocol();
     $this->initializeLocale();
     $this->initializeTrace();
     $this->initializeRepeater();
     #		$this->initializeSecurity();
     $this->initializeNamespace();
     #Benchmark::stop('Dev');
     #echo "DEV ";
     #BaseHelperMessage::showMessage(Benchmark::getBenchmarkTime('Dev'),array(BaseHelperEscapeChars::getEscapeChar('BR')));
     #Benchmark::start('NSP');
     #Benchmark::stop('SYS');
     #echo "SYS ";
     #BaseHelperMessage::showMessage(Benchmark::getBenchmarkTime('SYS'),array(BaseHelperEscapeChars::getEscapeChar('BR')));
     #Benchmark::start('SYS');
     #Benchmark::stop('SYS');
     #echo "SYS ";
     #BaseHelperMessage::showMessage(Benchmark::getBenchmarkTime('SYS'),array(BaseHelperEscapeChars::getEscapeChar('BR')));
     #Benchmark::stop('SYS');
     #echo "SYS ";
     #BaseHelperMessage::showMessage(Benchmark::getBenchmarkTime('SYS'),array(BaseHelperEscapeChars::getEscapeChar('BR')));
     #Benchmark::stop('NSP');
     #echo "NSP ";
     #BaseHelperMessage::showMessage(Benchmark::getBenchmarkTime('NSP'),array(BaseHelperEscapeChars::getEscapeChar('BR')));
     #Benchmark::start('SYS');
     $this->initializeCache();
     $this->initializeORM();
     $this->initializeDatabase();
     $this->initializeShutdown();
     #Benchmark::stop('SYS');
     #echo "SYS ";
     #BaseHelperMessage::showMessage(Benchmark::getBenchmarkTime('SYS'),array(BaseHelperEscapeChars::getEscapeChar('BR')));
 }
开发者ID:DevSKolb,项目名称:FLOWLite,代码行数:50,代码来源:Bootstrap.php

示例8: 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

示例9: posts

    $sql = "INSERT INTO posts (category_id, title, contents) VALUES (0, '%s', '%s')";
    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,代码行数:31,代码来源:t.php

示例10: array

<?php

$time = array();
$mem = array();
include 'Benchmark.php';
$benchmark = new Benchmark();
if (!empty($_POST)) {
    ob_start();
    foreach ($_POST['code'] as $code) {
        for ($n = 0; $n < $_POST['iterations']; $n++) {
            $benchmark->start();
            eval($code);
            $benchmark->finish();
        }
        $time[] = $benchmark->get_time();
        $mem[] = $benchmark->get_memory();
        $benchmark->flush();
    }
    ob_end_clean();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PHP Benchmark</title>
<style type="text/css">
* { margin:0; padding:0; }
body { font:90% Arial, Helvetica, sans-serif; padding:2em; }
form textarea, form input { font-family:"Courier New", Courier, monospace; }
.block { float:left; }
开发者ID:laiello,项目名称:php-benchmark-tool-and-class,代码行数:31,代码来源:index.php

示例11: render

 /**
  * Renders the Debug Toolbar
  *
  * @param bool print rendered output
  * @return string debug toolbar rendered output
  */
 public static function render($print = false)
 {
     Benchmark::start(self::$benchmark_name);
     $template = new View('toolbar');
     // Database panel
     if (Kohana::config('debug_toolbar.panels.database') === TRUE) {
         $template->set('queries', self::get_queries());
     }
     // Logs panel
     if (Kohana::config('debug_toolbar.panels.logs') === TRUE) {
         $template->set('logs', self::get_logs());
     }
     // Vars and Config panel
     if (Kohana::config('debug_toolbar.panels.vars_and_config') === TRUE) {
         $template->set('configs', self::get_configs());
     }
     // Files panel
     if (Kohana::config('debug_toolbar.panels.files') === TRUE) {
         $template->set('files', self::get_files());
     }
     // FirePHP
     if (Kohana::config('debug_toolbar.firephp_enabled') === TRUE) {
         self::firephp();
     }
     // Set alignment for toolbar
     switch (Kohana::config('debug_toolbar.align')) {
         case 'right':
         case 'center':
         case 'left':
             $template->set('align', Kohana::config('debug_toolbar.align'));
             break;
         default:
             $template->set('align', 'left');
     }
     // Javascript for toolbar
     $template->set('scripts', file_get_contents(Kohana::find_file('views', 'toolbar', TRUE, 'js')));
     // CSS for toolbar
     $styles = file_get_contents(Kohana::find_file('views', 'toolbar', FALSE, 'css'));
     Benchmark::stop(self::$benchmark_name);
     // Benchmarks panel
     if (Kohana::config('debug_toolbar.panels.benchmarks') === TRUE) {
         $template->set('benchmarks', self::get_benchmarks());
     }
     if (Event::$data and self::is_enabled()) {
         // Try to add css just before the </head> tag
         if (stripos(Event::$data, '</head>') !== FALSE) {
             Event::$data = str_ireplace('</head>', $styles . '</head>', Event::$data);
         } else {
             // No </head> tag found, append styles to output
             $template->set('styles', $styles);
         }
         // Try to add js and HTML just before the </body> tag
         if (stripos(Event::$data, '</body>') !== FALSE) {
             Event::$data = str_ireplace('</body>', $template->render() . '</body>', Event::$data);
         } else {
             // Closing <body> tag not found, just append toolbar to output
             Event::$data .= $template->render();
         }
     } else {
         $template->set('styles', $styles);
         return $template->render($print);
     }
 }
开发者ID:brojasmeneses,项目名称:floreriarosabel,代码行数:69,代码来源:Debug_Toolbar.php

示例12: executeAction

 public static function executeAction($controller, $action, $params)
 {
     $controller_class = Inflector::camelize($controller);
     $controller_class_name = $controller_class . 'Controller';
     // get a instance of that controller
     if (class_exists($controller_class_name)) {
         $controller = new $controller_class_name();
     }
     if (!$controller instanceof Controller) {
         throw new Exception("Class '{$controller_class_name}' does not extends Controller class!");
     }
     Observer::notify('system.execute');
     Benchmark::start('execute');
     // execute the action
     $controller->execute($action, $params);
 }
开发者ID:silentworks,项目名称:the-compressor,代码行数:16,代码来源:Simplengine.php

示例13: is_link

is_link(KOHANA) and chdir(dirname(realpath(__FILE__)));
$kohana_application = file_exists($kohana_application) ? $kohana_application : DOCROOT . $kohana_application;
$kohana_modules = file_exists($kohana_modules) ? $kohana_modules : DOCROOT . $kohana_modules;
$kohana_system = file_exists($kohana_system) ? $kohana_system : DOCROOT . $kohana_system;
define('APPPATH', str_replace('\\', '/', realpath($kohana_application)) . '/');
define('MODPATH', str_replace('\\', '/', realpath($kohana_modules)) . '/');
define('SYSPATH', str_replace('\\', '/', realpath($kohana_system)) . '/');
unset($kohana_application, $kohana_modules, $kohana_system);
//From Bootstrap.php
define('KOHANA_VERSION', '2.3.4');
define('KOHANA_CODENAME', 'buteo regalis');
define('KOHANA_IS_WIN', DIRECTORY_SEPARATOR === '\\');
define('SYSTEM_BENCHMARK', 'system_benchmark');
require SYSPATH . 'core/Benchmark' . EXT;
Benchmark::start(SYSTEM_BENCHMARK . '_total_execution');
Benchmark::start(SYSTEM_BENCHMARK . '_kohana_loading');
require SYSPATH . 'core/utf8' . EXT;
require SYSPATH . 'core/Event' . EXT;
require SYSPATH . 'core/Kohana' . EXT;
Kohana::setup();
//Extras
restore_error_handler();
restore_exception_handler();
class Console extends Controller
{
    var $template = 'kohana_error_disabled';
    public static function debug($message = NULL)
    {
        echo $message . "\n";
    }
}
开发者ID:kfdm-archive,项目名称:dev.kfdm.net,代码行数:31,代码来源:_cmd.php

示例14: show_load_time

<?php

// Start Benchmark
include 'class/benchmark.php';
Benchmark::start('Load Time');
$app->add_event('after_render_layout', 'show_load_time');
function show_load_time($layout)
{
    $layout .= '<style type="text/css">
				div.cms_debug{
				background-color: white;
				position: fixed;
				bottom:0;
				-moz-box-shadow:0 -1px 4px #000;
				box-shadow:0 -1px 4px #000;
				-webkit-box-shadow:0 -1px 4px #000;
				padding: 2px 4px 0 4px;
				left:10px;
				opacity:0.3;
			}
			div.cms_debug:hover{
				opacity:1;
			}
		</style>';
    Benchmark::stop('Load Time');
    $layout .= '<div class="cms_debug">';
    foreach (Benchmark::get_totals() as $total) {
        $layout .= $total . '<br>';
    }
    $layout .= '</div>';
}
开发者ID:sook,项目名称:drumon_framework,代码行数:31,代码来源:init.php

示例15: echo_formatted_data

 private function echo_formatted_data($data, $datatype)
 {
     Benchmark::start('echo_formatted_data');
     switch (strtolower($datatype)) {
         case 'json':
             header('Content-type: application/json');
             $json = json_encode($data);
             $callback = $this->input->get('jsonp_callback');
             if ($callback) {
                 echo $callback . '(' . $json . ');';
             } else {
                 echo $json;
             }
             break;
         case 'xml':
             header('Content-type: application/xml');
             $xml = '<?xml version="1.0" encoding="UTF-8"?><result></result>';
             $xml = simplexml_load_string($xml);
             $this->create_xml_object($xml, $data);
             $dom = new DOMDocument('1.0');
             $dom->preserveWhiteSpace = false;
             $dom->formatOutput = true;
             $dom->loadXML($xml->asXML());
             echo $dom->saveXML();
             break;
         default:
             throw new Kohana_404_Exception();
             break;
     }
     Benchmark::stop('echo_formatted_data');
 }
开发者ID:vshulman,项目名称:uwdata.ca,代码行数:31,代码来源:v1.php


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