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


PHP getMicrotime函数代码示例

本文整理汇总了PHP中getMicrotime函数的典型用法代码示例。如果您正苦于以下问题:PHP getMicrotime函数的具体用法?PHP getMicrotime怎么用?PHP getMicrotime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: stopTimer

 /**
  * Stop a benchmarking timer.
  *
  * $name should be the same as the $name used in startTimer().
  *
  * @param string $name The name of the timer to end.
  * @access public
  * @return boolean true if timer was ended, false if timer was not started.
  * @static
  */
 function stopTimer($name = null)
 {
     $end = getMicrotime();
     $_this = DebugKitDebugger::getInstance();
     if (!$name) {
         $names = array_reverse(array_keys($_this->__benchmarks));
         foreach ($names as $name) {
             if (!empty($_this->__benchmarks[$name]['end'])) {
                 continue;
             }
             if (empty($_this->__benchmarks[$name]['named'])) {
                 break;
             }
         }
     } else {
         $i = 1;
         $_name = $name;
         while (isset($_this->__benchmarks[$name])) {
             if (empty($_this->__benchmarks[$name]['end'])) {
                 break;
             }
             $i++;
             $name = $_name . ' #' . $i;
         }
     }
     if (!isset($_this->__benchmarks[$name])) {
         return false;
     }
     $_this->__benchmarks[$name]['end'] = $end;
     return true;
 }
开发者ID:masayukiando,项目名称:cakephp1.3-mailmagazine,代码行数:41,代码来源:debug_kit_debugger.php

示例2: cached

	function cached($url) {
		if (Configure::read('Cache.check') === true) {
			$path = $this->here;
			if ($this->here == '/') {
				$path = 'home';
			}
			if($this->Session->check('Auth.User._id')){
				//$path = $_SESSION['Auth']['User']['_id'].'_'.strtolower(Inflector::slug($path));
				$path = '4d33940fda220a9606000003_'.strtolower(Inflector::slug($path));
			}else{
				$path = strtolower(Inflector::slug($path));
			}

			$filename = CACHE . 'views' . DS . $path . '.php';

			if (!file_exists($filename)) {
				$filename = CACHE . 'views' . DS . $path . '_index.php';
			}

			if (file_exists($filename)) {
				if (!class_exists('View')) {
					App::import('View', 'View', false);
				}
				$controller = null;
				$view =& new View($controller);
				$return = $view->renderCache($filename, getMicrotime());
				if (!$return) {
					ClassRegistry::removeObject('view');
				}
				return $return;
			}
		}
		return false;
	}
开发者ID:ninetwentyfour,项目名称:Homkora,代码行数:34,代码来源:my_dispatcher.php

示例3: insertMessage

 public static function insertMessage($user_id, $chat_id, $message)
 {
     $conn = DbHandler::getConnection();
     $query = "INSERT INTO messages (chat_id, user_id, message, insert_time) " . "VALUES (" . $conn->escapeString($chat_id) . ", " . $conn->escapeString($user_id) . ", '" . $conn->escapeString($message) . "', " . $conn->escapeString(getMicrotime()) . ")";
     $conn->exec($query);
     UserHandler::setUserActivity();
     return true;
 }
开发者ID:krixisLv,项目名称:SimpleChat,代码行数:8,代码来源:MessageHandler.php

示例4: end

 public function end()
 {
     if (is_null($this->startTime) || !is_null($this->endTime)) {
         return false;
     }
     $this->endTime = getMicrotime();
     $this->elapsedTime = round($this->endTime - $this->startTime, 3);
     return true;
 }
开发者ID:laiello,项目名称:fredistrano,代码行数:9,代码来源:logs.php

示例5: stopTimer

 /**
  * Stop a benchmarking timer.
  *
  * $name should be the same as the $name used in startTimer().
  *
  * @param string $name The name of the timer to end.
  * @access public
  * @return boolean true if timer was ended, false if timer was not started.
  * @static
  */
 function stopTimer($name = 'default')
 {
     $now = getMicrotime();
     $_this = DebugKitDebugger::getInstance();
     if (!isset($_this->__benchmarks[$name])) {
         return false;
     }
     $_this->__benchmarks[$name]['end'] = $now;
     return true;
 }
开发者ID:kondrat,项目名称:agift,代码行数:20,代码来源:debug_kit_debugger.php

示例6: createUser

 protected static function createUser($username)
 {
     require_once "handlers/ChatHandler.php";
     $conn = DbHandler::getConnection();
     $query = "INSERT INTO users (username, last_activity) VALUES ( '" . $conn->escapeString($username) . "', " . $conn->escapeString(getMicrotime()) . " )";
     $conn->exec($query);
     $user_id = $conn->lastInsertRowID();
     // add user rel to public chat
     ChatHandler::addUserChatRel($user_id, ChatHandler::PUBLIC_CHAT_ID);
     return $user_id;
 }
开发者ID:krixisLv,项目名称:SimpleChat,代码行数:11,代码来源:UserHandler.php

示例7: endCount

 function endCount()
 {
     global $_runtime, $_SERVER, $db, $cac;
     $_runtime['Timer']['UserCodeFinished'] = getMicrotime();
     $runtimecore = $_runtime['Timer']['InitFinished'] - $_runtime['Timer']['InitStart'];
     $runtimeuser = $_runtime['Timer']['UserCodeFinished'] - $_runtime['Timer']['UserCodeStart'];
     $runtimetotal = $runtimecore + $runtimeuser;
     $runtimeava = (file_get_contents(PROJECT_ROOT . '/p-ava.log') + $runtimetotal) / 2;
     file_put_contents(PROJECT_ROOT . '/p.log', sprintf('[Performance Log] Total Running time: %s (Core code %s, User code %s); Database query: %s (%s failed); Cache query: %sr / %sw; Men usage: %s kilobytes (peak: %s kilobytes); URL: %s' . "\r\n", $runtimetotal, $runtimecore, $runtimeuser, $db->count['Success'], $db->count['Failed'], $cac->count['Readed'], $cac->count['Written'], memory_get_usage(true) / 1024, memory_get_peak_usage(true) / 1024, $_SERVER['REQUEST_URI']), FILE_APPEND);
     file_put_contents(PROJECT_ROOT . '/p-ava.log', $runtimeava);
 }
开发者ID:BGCX067,项目名称:faculaframework-svn-to-git,代码行数:11,代码来源:index.php

示例8: mysqlQuery

function mysqlQuery($config, $request, $report)
{
    $mysql = mysqlAccess($config);
    $start_time = getMicrotime();
    //		$show_time = true;
    if (!isset($request['mode'])) {
        $request['mode'] = 'SELECT';
    }
    $request['model'] = $GLOBALS['model'][$GLOBALS['controller']]['model'];
    if ($GLOBALS['debug'] == true) {
        print_r($request);
    }
    $db_result = buildQuery($mysql, $request, $start_time, $report);
    // Return MySQL query result and query:
    return array('result' => $db_result['result'], 'query' => $db_result['query']);
    // Close MySQL connection:
    $mysql->close();
}
开发者ID:chogsden,项目名称:file-browser,代码行数:18,代码来源:functions.php

示例9: hashFileSavePath

/**
 * 散列存储
 * @param $savePath - 本地保存的路径
 * @param $fileName - 原始文件名
 * @param $isHashSaving - 是否散列存储。
 * @param $randomFileName - 是否生成随机的Hash文件名。
 * @return array
 **/
function hashFileSavePath($savePath, $fileName = '', $isHashSaving = true, $randomFileName = true)
{
    $hashFileName = $randomFileName ? md5(randStr(20) . $fileName . getMicrotime() . uniqid()) : md5($fileName);
    $fileSaveDir = $savePath;
    $hashFilePath = '';
    //是否散列存储。
    if ($isHashSaving) {
        $hashFilePath = substr($hashFileName, 0, 1) . DIRECTORY_SEPARATOR . substr($hashFileName, 1, 2);
        $fileSaveDir = $savePath . DIRECTORY_SEPARATOR . $hashFilePath;
    }
    $fileInfo = array("file_path" => $hashFilePath, "file_name" => $hashFileName, "error" => 0);
    if (!is_dir($fileSaveDir)) {
        $result = mkdir($fileSaveDir, 0777, true);
        if (!$result) {
            $fileInfo["error"] = 1;
        }
    }
    return $fileInfo;
}
开发者ID:Rming,项目名称:novophp,代码行数:27,代码来源:Helper.func.php

示例10: execute

 /**
  * Queries the database with given SQL statement, and obtains some metadata about the result
  * (rows affected, timing, any errors, number of rows in resultset). The query is also logged.
  * If DEBUG is set, the log is shown all the time, else it is only shown on errors.
  *
  * @param string $sql
  * @return unknown
  */
 function execute($sql)
 {
     $t = getMicrotime();
     $this->_result = $this->_execute($sql);
     $this->affected = $this->lastAffected();
     $this->took = round((getMicrotime() - $t) * 1000, 0);
     $this->error = $this->lastError();
     $this->numRows = $this->lastNumRows($this->_result);
     if ($this->fullDebug && Configure::read() > 1) {
         $this->logQuery($sql);
     }
     if ($this->error) {
         $this->showQuery($sql);
         return false;
     } else {
         return $this->_result;
     }
 }
开发者ID:uwitec,项目名称:eduoa,代码行数:26,代码来源:dbo_source.php

示例11: _executeQuery

    function _executeQuery($queryData = array (), $cache = true) {

        $t = getMicrotime();
        $query = $this->_queryToString($queryData);
        if ($cache && isset ($this->_queryCache[$query])) {
            if (strpos(trim(strtolower($query)), $queryData['type']) !== false) {
                $res = $this->_queryCache[$query];
            }
        } else {        
            switch ($queryData['type']) {
                case 'search':
                    // TODO pb ldap_search & $queryData['limit']
                    if ($res = @ ldap_search($this->connection, $queryData['targetDn'] . ',' . $this->config['basedn'],
                            $queryData['conditions'], $queryData['fields'], 0, $queryData['limit'])) {
                        if ($cache) {
                            if (strpos(trim(strtolower($query)), $queryData['type']) !== false) {
                                $this->_queryCache[$query] = $res;
                            }
                        }
                    } else{
                        $res = false;
                    }
                    break;
                case 'delete':
                    $res = @ ldap_delete($this->connection, $queryData['targetDn'] . ',' . $this->config['basedn']);             
                    break;
                default:
                    $res = false;
                    break;
            }
        }
                
        $this->_result = $res;
        $this->took = round((getMicrotime() - $t) * 1000, 0);
        $this->error = $this->lastError();
        $this->numRows = $this->lastNumRows();

        if ($this->fullDebug) {
            $this->logQuery($query);
        }

        return $this->_result;
    }
开发者ID:recruitcojp,项目名称:WebHive,代码行数:43,代码来源:ldap_source.php

示例12: define

 * Editing below this line should not be necessary.
 * Change at your own risk.
 *
 */
if (!defined('WEBROOT_DIR')) {
    define('WEBROOT_DIR', basename(dirname(__FILE__)));
}
if (!defined('WWW_ROOT')) {
    define('WWW_ROOT', dirname(__FILE__) . DS);
}
if (!defined('CORE_PATH')) {
    if (function_exists('ini_set') && ini_set('include_path', CAKE_CORE_INCLUDE_PATH . PATH_SEPARATOR . ROOT . DS . APP_DIR . DS . PATH_SEPARATOR . ini_get('include_path'))) {
        define('APP_PATH', null);
        define('CORE_PATH', null);
    } else {
        define('APP_PATH', ROOT . DS . APP_DIR . DS);
        define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
    }
}
if (!(include CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
    trigger_error("CakePHP core could not be found.  Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php.  It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
}
if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
    return;
} else {
    $Dispatcher = new Dispatcher();
    $Dispatcher->dispatch($url);
}
if (Configure::read() > 0) {
    echo "<!-- " . round(getMicrotime() - $TIME_START, 4) . "s -->";
}
开发者ID:BackupTheBerlios,项目名称:openphysic-svn,代码行数:31,代码来源:index.php

示例13: read

 /**
  * Used to read records from the Datasource. The "R" in CRUD
  *
  * @param Model $model The model being read.
  * @param array $queryData An array of query data used to find the data you want
  * @return mixed
  */
 public function read(&$model, $queryData = array())
 {
     if (!isset($model->records) || !is_array($model->records) || empty($model->records)) {
         $this->_requestsLog[] = array('query' => 'Model ' . $model->alias, 'error' => __('No records found in model.', true), 'affected' => 0, 'numRows' => 0, 'took' => 0);
         return array($model->alias => array());
     }
     $startTime = getMicrotime();
     $data = array();
     $i = 0;
     $limit = false;
     if (!isset($queryData['recursive'])) {
         $queryData['recursive'] = $model->recursive;
     }
     if (is_integer($queryData['limit']) && $queryData['limit'] > 0) {
         $limit = $queryData['page'] * $queryData['limit'];
     }
     foreach ($model->records as $pos => $record) {
         // Tests whether the record will be chosen
         if (!empty($queryData['conditions'])) {
             $queryData['conditions'] = (array) $queryData['conditions'];
             if (!$this->conditionsFilter($model, $record, $queryData['conditions'])) {
                 continue;
             }
         }
         $data[$i][$model->alias] = $record;
         $i++;
         // Test limit
         if ($limit !== false && $i == $limit && empty($queryData['order'])) {
             break;
         }
     }
     if ($queryData['fields'] === 'COUNT') {
         $this->_registerLog($model, $queryData, getMicrotime() - $startTime, 1);
         if ($limit !== false) {
             $data = array_slice($data, ($queryData['page'] - 1) * $queryData['limit'], $queryData['limit'], false);
         }
         return array(array(array('count' => count($data))));
     }
     // Order
     if (!empty($queryData['order'])) {
         if (is_string($queryData['order'][0])) {
             $field = $queryData['order'][0];
             $alias = $model->alias;
             if (strpos($field, '.') !== false) {
                 list($alias, $field) = explode('.', $field, 2);
             }
             if ($alias === $model->alias) {
                 $sort = 'ASC';
                 if (strpos($field, ' ') !== false) {
                     list($field, $sort) = explode(' ', $field, 2);
                 }
                 $data = Set::sort($data, '{n}.' . $model->alias . '.' . $field, $sort);
             }
         }
     }
     // Limit
     if ($limit !== false) {
         $data = array_slice($data, ($queryData['page'] - 1) * $queryData['limit'], $queryData['limit'], false);
     }
     // Filter fields
     if (!empty($queryData['fields'])) {
         $listOfFields = array();
         foreach ($queryData['fields'] as $field) {
             if (strpos($field, '.') !== false) {
                 list($alias, $field) = explode('.', $field, 2);
                 if ($alias !== $model->alias) {
                     continue;
                 }
             }
             $listOfFields[] = $field;
         }
         foreach ($data as $id => $record) {
             foreach ($record[$model->alias] as $field => $value) {
                 if (!in_array($field, $listOfFields)) {
                     unset($data[$id][$model->alias][$field]);
                 }
             }
         }
     }
     $this->_registerLog($model, $queryData, getMicrotime() - $startTime, count($data));
     $_associations = $model->__associations;
     if ($queryData['recursive'] > -1) {
         foreach ($_associations as $type) {
             foreach ($model->{$type} as $assoc => $assocData) {
                 $linkModel =& $model->{$assoc};
                 if ($model->useDbConfig == $linkModel->useDbConfig) {
                     $db =& $this;
                 } else {
                     $db =& ConnectionManager::getDataSource($linkModel->useDbConfig);
                 }
                 if (isset($db)) {
                     if (method_exists($db, 'queryAssociation')) {
                         $stack = array($assoc);
//.........这里部分代码省略.........
开发者ID:radig,项目名称:datasources,代码行数:101,代码来源:array_source.php

示例14: getTimers

 /**
  * Get all timers that have been started and stopped.
  * Calculates elapsed time for each timer. If clear is true, will delete existing timers
  *
  * @param bool $clear false
  * @return array
  * @access public
  **/
 function getTimers($clear = false)
 {
     $_this =& DebugKitDebugger::getInstance();
     $start = DebugKitDebugger::requestStartTime();
     $now = getMicrotime();
     $times = array();
     if (!empty($_this->__benchmarks)) {
         $firstTimer = current($_this->__benchmarks);
         $_end = $firstTimer['start'];
     } else {
         $_end = $now;
     }
     $times['Core Processing (Derived)'] = array('message' => __d('debug_kit', 'Core Processing (Derived)', true), 'start' => 0, 'end' => $_end - $start, 'time' => round($_end - $start, 6), 'named' => null);
     foreach ($_this->__benchmarks as $name => $timer) {
         if (!isset($timer['end'])) {
             $timer['end'] = $now;
         }
         $times[$name] = array_merge($timer, array('start' => $timer['start'] - $start, 'end' => $timer['end'] - $start, 'time' => DebugKitDebugger::elapsedTime($name)));
     }
     if ($clear) {
         $_this->__benchmarks = array();
     }
     return $times;
 }
开发者ID:ambagasdowa,项目名称:kml,代码行数:32,代码来源:debug_kit_debugger.php

示例15: stopMicrotime

function stopMicrotime($start_time)
{
    return number_format(getMicrotime() - $start_time, 6) * 1000;
}
开发者ID:chogsden,项目名称:file-browser,代码行数:4,代码来源:functions.php


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