本文整理汇总了PHP中microtime_float函数的典型用法代码示例。如果您正苦于以下问题:PHP microtime_float函数的具体用法?PHP microtime_float怎么用?PHP microtime_float使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了microtime_float函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_time
function print_time($cmnt = '')
{
static $cal_nom = 0;
global $time_start;
$cal_nom++;
echo '<hr>time: ' . (microtime_float() - $time_start) * 1000 . " ms ({$cal_nom}) [{$cmnt}]<br>";
}
示例2: hit_
function hit_($url, $vhost = NULL, $login = NULL, $password = NULL)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
if (!empty($login) and !empty($password)) {
curl_setopt($ch, CURLOPT_USERPWD, "{$login}:{$password}");
}
if (!empty($vhost)) {
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Host: {$vhost}"));
}
curl_setopt($ch, CURLOPT_NOBODY, true);
$start = microtime_float();
if (!curl_exec($ch)) {
die("Cant exec curl request!");
}
$end = microtime_float();
$status = curl_getinfo($ch);
if ($status['http_code'] != 200) {
die("Http repsponse code {$status['http_code']} returned by {$url}!");
}
//print_r(curl_getinfo($ch));
curl_close($ch);
$delta = round($end - $start, 1);
if ($delta < 1) {
// echo ".";
$delta = round($end - $start, 1);
} else {
// echo "-${delta}-";
$delta = round($delta, 0);
}
return $delta;
}
示例3: GetOutput
public function GetOutput($Db)
{
/*<img src="http://image.eveonline.com/Character/<?php echo $chid; ?>_256.jpg" height=118 width=118>*/
$full_url = FULL_URL;
// TODO
$time_start = microtime_float();
$corpinf = cache_api_retrieve($Db, "/corp/CorporationSheet.xml.aspx", array("corporationID" => CORP_ID), 3 * 24 * 60 * 60)->value;
$this->Title = "About " . $corpinf->result->corporationName;
$time_end = microtime_float();
$time_api = $time_end - $time_start;
$this->Output .= <<<EOD
<table><tr><td>
<img src="http://image.eveonline.com/Corporation/{$corpinf->result->corporationID}_128.png" height=108 width=108>
</td><td valign=top>
<table>
<tr><td>CEO </td><td>{$corpinf->result->ceoName}</tr>
<tr><td>Members </td><td>{$corpinf->result->memberCount}</tr>
<tr><td>Tax </td><td>{$corpinf->result->taxRate}%</tr>
<tr><td>URL </td><td><a href="{$corpinf->result->url}" target="_blank">{$corpinf->result->url}</a></td></tr>
EOD;
if ((int) $corpinf->result->allianceID != 0) {
$this->Output .= "<tr><td>Alliance </td><td>" . $corpinf->result->allianceName . "</tr>";
}
$this->Output .= "\r\n\t\t</table>\r\n\t\t</td></table>\r\n\t\t<br>\r\n\t\t<div>";
$this->Output .= parse_ccptml($corpinf->result->description);
$this->Output .= "</div><br>";
$this->Times = getPageTimes($Db, $time_api, microtime_float() - $time_start);
return true;
}
示例4: gwbbcodize
function gwbbcodize($t)
{
$start = microtime_float();
// Replace all '['s inside [pre]..[/pre] by '['
if (!defined('SMF')) {
//SMF uses the [pre] tag already
$t = preg_replace_callback('#\\[pre\\](.*?)\\[\\/pre\\]#isS', 'pre_replace', $t);
}
$t = preg_replace_callback('#\\[nobb\\](.*?)\\[\\/nobb\\]#isS', 'pre_replace', $t);
// [rand seed=465468 players=2]
$t = preg_replace_callback('#\\[rand([^\\]]*)\\]#isS', 'rand_replace', $t);
// Manage [build=...]
$t = preg_replace_callback('#\\[build=([^\\]]*)\\]\\]?(\\[/build\\])?\\r?\\n?#isS', 'build_id_replace', $t);
// Manage [build_name;template_code]
$t = preg_replace_callback('#\\[(([^]\\r\\n]+);([^];\\r\\n]+))\\]\\r?\\n?#isS', 'build_id_replace', $t);
// Replace all [skill_name] by [skill]skill_name[/skill] if skill_name is a valid skill name
$t = preg_replace_callback('#\\[(.*?)\\]#isS', 'skill_name_replace', $t);
// Manage [build]...[/build]
$t = preg_replace_callback('#\\[build ([^\\]]*)\\](.*?)\\[/build\\]\\r?\\n?#isS', 'build_replace', $t);
// Manage [skill]...[/skill]
$t = preg_replace_callback('#\\[skill([^\\]]*)\\](.*?)\\[/skill\\][ ]?#isS', 'skill_replace', $t);
// [pickup="arheu"]
$t = preg_replace_callback('#\\[pickup([^\\]]*)\\]#isS', 'pickup_replace', $t);
//[gwbbcode runtime]
if (preg_match('@\\[gwbbcode runtime\\]@i', $t) !== false) {
$t = preg_replace('@\\[gwbbcode runtime\\]@i', round(microtime_float() - $start, 3), $t);
}
//Precise enough
//Trick to use in MyBB against <p> elements screwing up first skill div, and some ending <br /> being removed
if (defined('IN_MYBB')) {
$t = '</p>' . $t;
$t = str_replace("</div>\n", "</div><br>", $t);
}
return $t;
}
示例5: de_jong
function de_jong(&$im, $x, $y, $a, $b, $c, $d)
{
$i = 0;
$xsize = imagesx($im);
$yzise = imagesy($im);
$xn = sin($a * $y) - cos($b * $x);
$yn = sin($c * $x) - cos($d * $y);
$x = $xn;
$y = $yn;
$time = microtime_float();
while (imagecolorat($im, round((imagesx($im) - 1) * $x / 4) + (imagesx($im) - 1) / 2, round((imagesy($im) - 1) * $y / 4) + (imagesy($im) - 1) / 2) !== 0xffffff) {
$i++;
$color = imagecolorat($im, round((imagesx($im) - 1) * $x / 4) + (imagesx($im) - 1) / 2, round((imagesy($im) - 1) * $y / 4) + (imagesy($im) - 1) / 2);
$color += 0x10101;
imagesetpixel($im, round((imagesx($im) - 1) * $x / 4) + (imagesx($im) - 1) / 2, round((imagesy($im) - 1) * $y / 4) + (imagesy($im) - 1) / 2, $color);
$xn = sin($a * $y) - cos($b * $x);
$yn = sin($c * $x) - cos($d * $y);
$x = $xn;
$y = $yn;
}
if (microtime_float() - $time > 0.1) {
echo "\r" . round($i / (microtime_float() - $time)) . " steps per second";
}
return $i;
}
示例6: query
function query($sql, $unbuffered = false)
{
if (strlen($sql) > 140000) {
exit('Insane query. Aborting.');
}
if (defined('OPENLD_SHOW_QUERIES')) {
$q_start = microtime_float();
}
if ($unbuffered) {
$this->query_result = @mysql_unbuffered_query($sql, $this->link_id);
} else {
$this->query_result = @mysql_query($sql, $this->link_id);
}
if ($this->query_result) {
if (defined('OPENLD_SHOW_QUERIES')) {
$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
}
++$this->num_queries;
return $this->query_result;
} else {
if (defined('OPENLD_SHOW_QUERIES')) {
$this->saved_queries[] = array($sql, 0);
}
return false;
}
}
示例7: query
function query($sql, $unbuffered = false)
{
if (strlen($sql) > 140000) {
exit('Insane query. Aborting.');
}
if (defined('OPENLD_SHOW_QUERIES')) {
$q_start = microtime_float();
}
$this->query_result = @mysqli_query($this->link_id, $sql);
if ($this->query_result) {
if (defined('OPENLD_SHOW_QUERIES')) {
$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
}
++$this->num_queries;
return $this->query_result;
} else {
if (defined('OPENLD_SHOW_QUERIES')) {
$this->saved_queries[] = array($sql, 0);
}
// Rollback transaction
if ($this->in_transaction) {
mysqli_query($this->link_id, 'ROLLBACK');
}
--$this->in_transaction;
return false;
}
}
示例8: microtime_run
function microtime_run()
{
$StartTime = empty($GLOBALS['StartTime']) ? microtime_float() : $GLOBALS['StartTime'];
$EndTime = microtime_float();
$RunTime = $EndTime - $StartTime;
return $RunTime;
}
示例9: test
function test($ip2c, $expected, $ip)
{
global $num;
global $total;
$ips = long2ip($ip);
// echo "$ip => $ips <br/>";
$now = microtime_float();
$country = $ip2c->get_country($ips);
$t = microtime_float() - $now;
$total += $t;
$num++;
if ($expected == false && $country == false) {
return;
}
if ($expected == false && $country != false) {
die("Expected " . var_export($expected, true) . ", got " . var_export($country, true) . " ||| {$ip} {$ips}");
}
if ($expected != false && $country == false) {
die("IP ({$ip} {$ips}) Not found, Expected :<br/>" . var_export($expected, true));
}
$id2c = $expected[2];
$id3c = $expected[3];
$name = $expected[4];
$o2c = $country['id2'];
$o3c = $country['id3'];
$oname = $country['name'];
if ($id2c != $country['id2'] || $id3c != $country['id3'] || $name != $country['name']) {
die("Expected :<br/>2c = {$id2c}, 3c = {$id3c} , name = {$name}<br/>got:<br/>2c = {$o2c}, 3c = {$o3c} , name = {$oname} :<br/> ||| {$ip} {$ips}");
}
}
示例10: check
/**
* Check a MediaFire link.
*
* @param string $url
* @return array
*/
function check($url)
{
$result = array('final_url' => $url, 'redirect_count' => 0, 'timeout' => false, 'broken' => false, 'log' => "<em>(Using MediaFire checker module)</em>\n\n", 'http_code' => 0, 'result_hash' => '');
//URLs like http://www.mediafire.com/download.php?03mj0mwmnnm are technically valid,
//but they introduce unnecessary redirects.
$url = str_replace('download.php', '', $url);
//Since MediaFire doesn't have an API, we just send a HEAD request
//and try do divine the file state from the response headers.
$start = microtime_float();
$rez = $this->head($url);
$result['request_duration'] = microtime_float() - $start;
if (is_wp_error($rez)) {
//An unexpected error.
$result['broken'] = true;
$result['log'] .= "Error : " . $rez->get_error_message();
if ($data = $rez->get_error_data()) {
$result['log'] .= "\n\nError data : " . print_r($data, true);
}
} else {
$result['http_code'] = intval($rez['response']['code']);
if ($result['http_code'] == 200) {
//200 - OK
$result['broken'] = false;
$result['log'] .= "File OK";
} elseif (isset($rez['headers']['location'])) {
//Redirect = some kind of error. Redirects to an error page with an explanatory message.
//The redirect URL is structured like this : '/error.php?errno=320'. The 'errno' argument
//contains an (undocumented) error code. The only known value is 'errno=320', which
//indicates that the file is invalid or has been deleted.
$result['broken'] = true;
if (strpos($rez['headers']['location'], 'errno=320') !== false) {
$result['status_code'] = BLC_LINK_STATUS_ERROR;
$result['status_text'] = __('Not Found', 'broken-link-checker');
$result['http_code'] = 0;
$result['log'] .= "The file is invalid or has been removed.";
} else {
if (strpos($rez['headers']['location'], 'errno=378') !== false) {
$result['status_code'] = BLC_LINK_STATUS_ERROR;
$result['status_text'] = __('Not Found', 'broken-link-checker');
$result['http_code'] = 0;
$result['log'] .= "The file has been removed due to a violation of MediaFire ToS.";
} else {
$result['status_code'] = BLC_LINK_STATUS_INFO;
$result['status_text'] = __('Unknown Error', 'broken-link-checker');
$result['log'] .= "Unknown error.\n\n";
foreach ($rez['headers'] as $name => $value) {
$result['log'] .= printf("%s: %s\n", $name, $value);
}
}
}
} else {
$result['log'] .= "Unknown error.\n\n" . implode("\n", $rez['headers']);
}
}
//Generate the result hash (used for detecting false positives)
$result['result_hash'] = implode('|', array('mediafire', $result['http_code'], $result['broken'] ? 'broken' : '0', $result['timeout'] ? 'timeout' : '0'));
return $result;
}
示例11: stopTimer
function stopTimer($message, $forceShow = false)
{
global $timerStartTimes;
$elapsed = microtime_float() - array_pop($timerStartTimes);
if (wcaDebug() || $forceShow) {
printf("<b>%.4f seconds</b> for '{$message}'<br />", $elapsed);
}
return $elapsed;
}
示例12: __construct
/**
*
* @param $filepath -
* @param $template -
* @param $filter CTraceFilter -
*/
function __construct($filepath, $template, CTraceFilter $filter)
{
$this->_file = new CFile($filepath);
$this->_filter = $filter;
// "[@id] [@level] [@date @time.@microtime] [@delta_time] [@mem] [@delta_mem] [@filepath] [@file:@line] [@class@func()]";
$this->_tpl_prefix = $template;
$this->_last_mem = memory_get_usage(true);
$this->_last_time = microtime_float();
}
示例13: endEvent
function endEvent($event_name)
{
if (!DEBUG) {
return false;
}
if (isset($GLOBALS['debug']['timer']['end'][$event_name])) {
$event_name = createNewEventName($event_name, $start);
}
$GLOBALS['debug']['timer']['end'][$event_name] = microtime_float();
}
示例14: ArcadeVbSubmit
function ArcadeVbSubmit(&$game, $session)
{
global $scripturl, $context, $modSettings, $smcFunc;
$diff = microtime_float() - $session['end_time'];
if ($diff > 4500 || !empty($session['ping'])) {
return false;
}
$session['ping'] = true;
$cheating = CheatingCheck();
unset($_SESSION['arcade_play_vb3g'][$_POST['id']]);
return array('cheating' => $cheating, 'score' => $session['score'], 'start_time' => $session['start_time'], 'duration' => round($session['end_time'] - $session['start_time'], 0), 'end_time' => round($session['end_time'], 0));
}
示例15: mysql_execute_sql
function mysql_execute_sql($connect_id, $sql_statement, $return_single_record_or_field = 0, $return_sql_result = 0)
{
global $sql_errors, $sql_debug, $sql_test, $sql_last_query_time;
//echo $sql_statement;
if (!$sql_statement) {
return;
}
#$sql_statement = preg_replace( "/\r|\n/", " ", $sql_statement );
if (!$sql_test) {
if ($connect_id) {
$time_start = microtime_float();
$sql_result = mysql_query($sql_statement, $connect_id);
$time_end = microtime_float();
} else {
$time_start = microtime_float();
$sql_result = mysql_query($sql_statement);
$time_end = microtime_float();
}
}
$sql_last_query_time = number_format($time_end - $time_start, 4);
if ($sql_debug or $sql_test) {
mysql_show_sql_statement($sql_statement, $sql_result, mysql_error());
}
if ($return_sql_result) {
return $sql_result;
}
if ($sql_result) {
if ($sql_result == 1) {
# SQL statements that dont return results return true or false
return 1;
} else {
if (!mysql_num_rows($sql_result)) {
# Confirms that the SQL was executed correctly but no results were returned
#return 1;
return array();
}
}
$x = 0;
while ($sql_record = mysql_fetch_assoc($sql_result)) {
$x++;
$return_array[$x] = $sql_record;
}
if ($x == 1 and $return_single_record_or_field) {
if (count($return_array[1]) == 1) {
$return_array = current($return_array[1]);
} else {
$return_array = $return_array[1];
}
}
return $return_array;
}
return 0;
}