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


PHP Timer::elapsed方法代码示例

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


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

示例1: query

 public function query($sql)
 {
     if ($this->log !== false) {
         $backtrace = debug_backtrace();
         if (isset($backtrace[1])) {
             $this->log->write($backtrace[1]['class'] . $backtrace[1]['type'] . $backtrace[1]['function'] . ': Sending SQL: ' . $sql, XBM_LOG_DEBUG);
         } else {
             $this->log->write('Sending SQL: ' . $sql, XBM_LOG_DEBUG);
         }
         $timer = new Timer();
     }
     $res = parent::query($sql);
     if ($this->log !== false) {
         $elapsed = $timer->elapsed();
         if (isset($backtrace[1])) {
             $this->log->write($backtrace[1]['class'] . $backtrace[1]['type'] . $backtrace[1]['function'] . ': Query took ' . $elapsed, XBM_LOG_DEBUG);
         } else {
             $this->log->write('Query took ' . $elapsed, XBM_LOG_DEBUG);
         }
     }
     return $res;
 }
开发者ID:zigo928,项目名称:xtrabackup-manager,代码行数:22,代码来源:dbConnection.class.php

示例2: createTables

 public static function createTables(\PDO $pdo_db, string $db_prefix, string $dbtype)
 {
     $create_table_results = array();
     $i = 0;
     define('PDO_SUCCESS', (string) '00000');
     // PDO gives an error code of string 00000 if successful. Not extremely helpful.
     $schema_files = new \DirectoryIterator('schema/' . $dbtype);
     foreach ($schema_files as $schema_filename) {
         $table_timer = new Timer();
         $table_timer->start();
         // Start benchmarking
         if ($schema_filename->isFile() && $schema_filename->getExtension() == 'sql') {
             // Since we are using strict types, the Directory Iterator returns an object, and we want a string to pass to mb_substr.
             $simple_filename = (string) $schema_filename->getFilename();
             // Routine to handle persistent database tables. If a SQL schema file starts with persist-, then it is a persistent table
             $persist_file = mb_substr($simple_filename, 0, 8) === 'persist-';
             if ($persist_file) {
                 $tablename = mb_substr($simple_filename, 8, -4);
             } else {
                 $tablename = mb_substr($simple_filename, 0, -4);
             }
             // Slurp the SQL call from schema, and turn it into an SQL string
             $sql_query = file_get_contents('schema/' . $dbtype . '/' . $schema_filename);
             // Replace the default prefix (tki_) with the chosen table prefix from the game
             $sql_query = preg_replace('/tki_/', $db_prefix, $sql_query);
             // Remove comments from SQL
             $RXSQLComments = '@(--[^\\r\\n]*)|(\\#[^\\r\\n]*)|(/\\*[\\w\\W]*?(?=\\*/)\\*/)@ms';
             $sql_query = $sql_query == '' ? '' : preg_replace($RXSQLComments, '', $sql_query);
             // FUTURE: Test handling invalid SQL to ensure it hits the error logger below AND the visible output during running
             $sth = $pdo_db->prepare($sql_query);
             $sth->execute();
             if ($pdo_db->errorCode() !== PDO_SUCCESS) {
                 $errorinfo = $pdo_db->errorInfo();
                 $create_table_results[$i]['result'] = $errorinfo[1] . ': ' . $errorinfo[2];
             } else {
                 $create_table_results[$i]['result'] = true;
             }
             // Db::logDbErrors($pdo_db, $execute_res, __LINE__, __FILE__); // Triggers errors because there is no DB
             $create_table_results[$i]['name'] = $db_prefix . $tablename;
             $table_timer->stop();
             $create_table_results[$i]['time'] = $table_timer->elapsed();
             $i++;
         }
     }
     return $create_table_results;
 }
开发者ID:thekabal,项目名称:tki,代码行数:46,代码来源:Schema.php

示例3: Timer

<?php

require_once "Timer.php";
$timer = new Timer();
?>
<HTML>
  <HEAD>
    <TITLE>Test Page (elapsed time: <?php 
echo $timer->elapsed();
?>
 seconds)</TITLE>
  </HEAD>
  <BODY>
    This is a simple test page.
    Elapsed time: <?php 
echo $timer->elapsed();
?>
 seconds.
  </BODY>
</HTML>
<!-- Final elapsed time: <?php 
echo $timer->elapsed();
?>
 seconds. -->
开发者ID:bqevin,项目名称:maths-flashcard,代码行数:24,代码来源:example.php

示例4: test

function test($obj, $func)
{
    global $count;
    $timer = new Timer();
    $timer->start();
    for ($i = 0; $i < $count; $i++) {
        $obj->{$func}(rand(0, $count * 10));
    }
    return round($timer->elapsed(), 6);
}
开发者ID:Atiragram,项目名称:poit-labs,代码行数:10,代码来源:script.php


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