本文整理汇总了PHP中getmicrotime函数的典型用法代码示例。如果您正苦于以下问题:PHP getmicrotime函数的具体用法?PHP getmicrotime怎么用?PHP getmicrotime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getmicrotime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printGenerationTime
function printGenerationTime()
{
$debug_time["end"] = getmicrotime();
if ($debug) {
echo "Page générée en " . round($debug_time["end"] - $debug_time["start"], 3) . " secondes";
}
}
示例2: safe_query
function safe_query($q = '', $debug = '', $unbuf = '')
{
global $DB, $txpcfg, $qcount, $qtime, $production_status;
$method = !$unbuf ? 'mysql_query' : 'mysql_unbuffered_query';
if (!$q) {
return false;
}
if ($debug or TXP_DEBUG === 1) {
dmp($q);
dmp(mysql_error());
// dmp(debug_backtrace());
}
$start = getmicrotime();
$result = $method($q, $DB->link);
$time = sprintf('%02.6f', getmicrotime() - $start);
@($qtime += $time);
@$qcount++;
if ($result === false and (@$production_status == 'debug' or @$production_status == 'test')) {
trigger_error(mysql_error() . n . $q, E_USER_ERROR);
}
trace_add("[SQL ({$time}): {$q}]");
if (!$result) {
return false;
}
return $result;
}
示例3: DoBenchmark
function DoBenchmark()
{
if (PHP_VERSION < 4.1) {
global $HTTP_GET_VARS;
$_GET = $HTTP_GET_VARS;
}
$ITER = isset($_GET['iter']) ? (int) $_GET['iter'] : 1000;
$SWAP = function_exists('bench2') && !empty($_GET['swap']);
if ($ITER > 10000) {
die("DOS attack?");
}
flush();
$t1 = getmicrotime();
for ($i = $ITER; --$i >= 0;) {
_bench1();
}
$overhead = getmicrotime() - $t1;
//printf("oh=%8.6f ",$overhead);
if ($SWAP) {
$time2 = dobench2($ITER) - $overhead;
} else {
$time1 = dobench1($ITER) - $overhead;
}
if (function_exists('bench2')) {
if ($SWAP) {
$time1 = dobench1($ITER) - $overhead;
} else {
$time2 = dobench2($ITER) - $overhead;
}
printf("##%8.4f##%8.4f##", abs($time1) * (1000.0 / $ITER), abs($time2) * (1000.0 / $ITER));
} else {
printf("##%8.4f##", $time1);
}
}
示例4: EndMeasure
/**
* Ending measurement
*
* Ending measurement of time for specified block
*
* @param string $mpoint monitoring block name
*/
function EndMeasure($mpoint, $save_to_db = 0)
{
global $perf_data;
if (!$perf_data[$mpoint]['START']) {
return;
}
$perf_data[$mpoint]['END'] = getmicrotime();
if (!$perf_data[$mpoint]['MEMORY_END'] && function_exists('memory_get_usage')) {
$perf_data[$mpoint]['MEMORY_END'] = memory_get_usage();
}
$perf_data[$mpoint]['TIME'] += $perf_data[$mpoint]['END'] - $perf_data[$mpoint]['START'];
$perf_data[$mpoint]['NUM']++;
return;
if ($save_to_db) {
global $db;
if ($db->dbh) {
$rec = array();
$rec['OPERATION'] = substr($mpoint, 0, 200);
$rec['COUNTER'] = 1;
$rec['TIMEUSED'] = $perf_data[$mpoint]['TIME'];
$rec['ADDED'] = date('Y-m-d H:i:s');
if ($_SERVER['REQUEST_URI']) {
$rec['SOURCE'] = 'web';
} else {
$rec['SOURCE'] = 'cmd';
}
SQLInsert('performance_log', $rec);
}
}
}
示例5: SaveHTTPFile
function SaveHTTPFile($fFileHTTPPath, $fFileSavePath, $fFileSaveName)
{
//记录程序开始的时间
$BeginTime = getmicrotime();
//取得文件名
$fFileSaveName = $fFileSavePath . "/" . $fFileSaveName;
make_dir(dirname($fFileSaveName));
//取得文件的内容
ob_start();
readfile($fFileHTTPPath);
$img = ob_get_contents();
ob_end_clean();
//$size = strlen($img);
//保存到本地
$fp2 = @fopen($fFileSaveName, "a");
fwrite($fp2, $img);
fclose($fp2);
/*加水印代码*/
require_once ROOT_PATH . 'includes/cls_image.php';
$ext = get_extension($fFileSaveName);
$fFileSaveName = convert_GIF_to_JPG($fFileSaveName);
if (CopyFiles($fFileSaveName)) {
$image = new cls_image();
$image->add_watermark($fFileSaveName, '', '../../../../' . $GLOBALS['waterMark']['watermark'], $GLOBALS['waterMark']['watermark_place'], $GLOBALS['waterMark']['watermark_alpha']);
}
if ($ext == 'gif' || $ext == '.gif') {
back_JPG_to_GIF($fFileSaveName);
}
/*加水印代码--end*/
//记录程序运行结束的时间
$EndTime = getmicrotime();
//返回运行时间
return $EndTime - $BeginTime;
}
示例6: safe_query
function safe_query($q = '', $debug = '', $unbuf = '')
{
global $DB, $txpcfg, $qcount, $qtime, $production_status;
$method = !$unbuf ? 'mysql_query' : 'mysql_unbuffered_query';
if (!$q) {
return false;
}
if ($debug or TXP_DEBUG === 1) {
dmp($q);
}
$start = getmicrotime();
$result = $method($q, $DB->link);
$time = sprintf('%02.6f', getmicrotime() - $start);
@($qtime += $time);
@$qcount++;
if ($result === false and (txpinterface === 'admin' or @$production_status == 'debug' or @$production_status == 'testing')) {
$caller = $production_status == 'debug' ? n . join("\n", get_caller()) : '';
trigger_error(mysql_error() . n . $q . $caller, E_USER_WARNING);
}
trace_add("[SQL ({$time}): {$q}]");
if (!$result) {
return false;
}
return $result;
}
示例7: set_profiling
function set_profiling()
{
if (USE_PROFILING) {
global $start_exec_time;
$start_exec_time = getmicrotime();
}
}
示例8: get_physical_dmg_multiplier
function get_physical_dmg_multiplier(&$pa, &$pd, $active)
{
if (eval(__MAGIC__)) {
return $___RET_VALUE;
}
$r = array();
if (\skillbase\skill_query(262, $pa) && check_unlocked262($pa) && $pa['user_commanded'] == 1 && $active && !$pa['is_counter'] && (!isset($pa['sk262flag']) || !$pa['sk262flag'])) {
eval(import_module('logger'));
$ct = floor(getmicrotime() * 1000);
$st = (int) \skillbase\skill_getvalue(262, 'ct', $pa);
$t = $ct - $st;
//$log.='t='.$t;
$pretime = skill262_get_pretime($pa);
$dmgperc = skill262_get_dmgperc($pa);
$maxdmgperc = skill262_get_maxdmgperc($pa);
//$log.=' pretime='.$pretime.' dmgperc='.$dmgperc.' maxdmgperc='.$maxdmgperc;
if ($t < $pretime) {
$z = 0;
} else {
$z = ($t - $pretime) / 1000 * $dmgperc;
$z = min($z, $maxdmgperc);
$z = round($z);
$log .= '<span class="lime">你积蓄力量打出了致命的一拳!伤害增加了' . $z . '%!</span><br>';
}
$r = array(1 + $z / 100);
}
return array_merge($r, $chprocess($pa, $pd, $active));
}
示例9: getEndTimer
function getEndTimer()
{
global $time_start_tmp;
$t = sprintf("%.2f", getmicrotime() - $time_start_tmp);
$t = str_replace(",", ".", $t);
return $t;
}
示例10: Connect
/**
* @return bool
*/
function Connect()
{
if (!extension_loaded('odbc')) {
$this->ErrorDesc = 'Can\'t load ODBC extension.';
setGlobalError($this->ErrorDesc);
$this->_log->WriteLine($this->ErrorDesc, LOG_LEVEL_ERROR);
return false;
}
if ($this->_log->Enabled) {
$ti = getmicrotime();
}
$this->_conectionHandle = @odbc_connect($this->_dbCustomConnectionString, $this->_user, $this->_pass, SQL_CUR_USE_ODBC);
if ($this->_conectionHandle && $this->_log->Enabled) {
$this->_log->WriteLine(':: connection time -> ' . (getmicrotime() - $ti));
}
if ($this->_conectionHandle) {
if ($this->_dbType == DB_MYSQL) {
@odbc_exec($this->_conectionHandle, 'SET NAMES utf8');
}
return true;
} else {
$this->_setSqlError();
return false;
}
}
示例11: Connect
/**
* @return bool
*/
function Connect()
{
//if ($this->_conectionHandle != false) return true;
if (!extension_loaded('mssql')) {
$this->ErrorDesc = 'Can\'t load MsSQL extension.';
setGlobalError($this->ErrorDesc);
$this->_log->WriteLine($this->ErrorDesc, LOG_LEVEL_ERROR);
return false;
}
if ($this->_log->Enabled) {
$ti = getmicrotime();
}
$this->_conectionHandle = @mssql_connect($this->_host, $this->_user, $this->_password);
if ($this->_conectionHandle && $this->_log->Enabled) {
$this->_log->WriteLine(':: connection time -> ' . (getmicrotime() - $ti));
}
if ($this->_conectionHandle) {
if (strlen($this->_dbName) > 0) {
$dbselect = @mssql_select_db($this->_dbName, $this->_conectionHandle);
if (!$dbselect) {
$this->_setSqlError();
$this->_conectionHandle = $dbselect;
@mssql_close($this->_conectionHandle);
return false;
}
}
return true;
} else {
$this->_setSqlError();
return false;
}
}
示例12: debug_output
function debug_output()
{
global $settings__time_debugging_enabled, $settings__query_debugging_enabled, $debug__script_started;
global $debug__query_array, $debug__query_time;
if (isset($settings__time_debugging_enabled) && $settings__time_debugging_enabled == 'y') {
if (isset($debug__script_started)) {
$debug__script_stopped = getmicrotime();
$time_needed = round(($debug__script_stopped - getmicrotime($debug__script_started)) * 1000, 3);
echo 'Overall query time: ' . round($debug__query_time * 1000, 3) . 'msec,<br>
Overall script time: ' . $time_needed . 'msec<BR><BR>';
} else {
echo 'No script start time found.<BR><BR>';
}
}
if (isset($settings__query_debugging_enabled) && $settings__query_debugging_enabled == 'y') {
$i = 0;
if (isset($debug__query_array)) {
echo 'Nb of queries: ' . count($debug__query_array) . '<BR>
<table border=0>';
foreach ($debug__query_array as $query) {
$i++;
echo '<tr><td valign="top"><B>' . $i . '.</b></td><td valign="top">' . round($query['time'] * 1000, 3) . 'msec </td><td>' . str_replace(array("\n", ","), array("<br />", ", "), $query['query']) . '</td></tr>';
}
echo '</table>';
}
}
}
示例13: getExpressionOptions
public static function getExpressionOptions($_expression, $_options)
{
$startLoadTime = getmicrotime();
$cmd = cmd::byId(str_replace('#', '', cmd::humanReadableToCmd($_expression)));
if (is_object($cmd)) {
$return['html'] = trim($cmd->toHtml('scenario', $_options));
} else {
try {
$return['html'] = getTemplate('core', 'scenario', $_expression . '.default');
if (is_json($_options)) {
$_options = json_decode($_options, true);
}
if (is_array($_options) && count($_options) > 0) {
foreach ($_options as $key => $value) {
$replace['#' . $key . '#'] = $value;
}
}
if (!isset($replace['#id#'])) {
$replace['#id#'] = rand();
}
$return['html'] = template_replace(cmd::cmdToHumanReadable($replace), $return['html']);
} catch (Exception $e) {
}
}
$replace = array('#uid#' => 'exp' . mt_rand());
$return['html'] = translate::exec(template_replace($replace, $return['html']), 'core/template/scenario/' . $_expression . '.default');
return $return;
}
示例14: querydb
/**
* Element
*
* Lets you determine whether an array index is set and whether it has a value.
* If the element is empty it returns NULL (or whatever you specify as the default value.)
*
* @param string
* @param array
* @param mixed
* @return mixed depends on what the array contains
*/
function querydb($query, $reply = 1, $CALLED_FUNCTION = "_common")
{
/*
Get function My sql query
*/
global $mysql, $MySQLi;
//$query = @mysql_escape_string($query); 'not efective while using id_xx='xxxxx'.. will esacepe 'xxxxx' to \'xxxxx\'
global $time_start, $pre_src, $pre_rpc, $pre_src2, $pre_rpc2;
//mysql_set_charset('utf8');
$MySQLi->query('SET NAMES utf8');
$MySQLi->query('SET CHARACTER SET utf8');
//HTML format for query
//$print_query = preg_replace($pre_src2,$pre_rpc2,$query);
$print_query = preg_replace($pre_src, $pre_rpc, $query);
if (GLOBAL_DISPLAY_MYSQL_QUERY == 1) {
// MENCETAL waktu eksekusi erserta eksekusi scriptnya
//global $_SERVER;
//$self = $_SERVER['PHP_SELF'];
$time_end = getmicrotime();
$time_query = $time_end - $time_start;
print "<div class=\"php_note\">" . sprintf("%6.5f", $time_query) . " (s)  > MySQL Query <b>{$CALLED_FUNCTION}</b> : <icode class='fsi'>{$print_query};</icode></div>";
}
if ($result = $MySQLi->query($query)) {
//-> WARNING! this function is DEPRECATED, see PHP Manual.chm
return $result;
} else {
if ($reply == 1 && GLOBAL_DISPLAY_ERRORS == 1) {
print "<div class=\"php_on_error\">Failed For Operand a Query = " . $print_query . ", <b>" . $MySQLi->error . "</b></div>";
}
}
}
示例15: process_all_maps
function process_all_maps($dir, $rootLevel, $prefixRemoveCharsArg)
{
set_time_limit(160);
$i = 0;
if ($rootLevel) {
$prefixRemoveChars = strlen(trim($dir, "/")) + 1;
} else {
$prefixRemoveChars = $prefixRemoveCharsArg;
}
$current_dir = opendir($dir);
while ($entryname = readdir($current_dir)) {
if (is_dir("{$dir}/{$entryname}") && $entryname != "." && $entryname != "..") {
// echo "<br>$dir/$entryname<br>";
process_all_maps($dir . "/" . $entryname, 0, $prefixRemoveChars);
} else {
if ($entryname != "." && $entryname != ".." && strtolower(substr($entryname, -4)) == ".sid") {
$filename = substr("{$dir}/{$entryname}", 0, -4);
echo "PROCESSING: {$filename}\n";
// Time the execution
$tstart = getmicrotime();
processMap($filename);
$tend = getmicrotime();
$totaltime = $tend - $tstart;
echo "{$totaltime} secs\n";
flush();
}
}
}
closedir($current_dir);
}