function runBenchmark($ip2c, $ips, $len) { $now = microtime_float(); $progress = $len / 20; for ($i = 0; $i < $len; $i++) { if ($i % $progress == 0 && $i != 0) { echo "."; flush(); } $ip2c->get_country($ips[$i]); } $t = microtime_float() - $now; println(); println($t . " ms for {$len} searches (" . $len / $t . " searches/sec)"); }
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>"; }
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; }
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; }
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; }
function microtime_run() { $StartTime = empty($GLOBALS['StartTime']) ? microtime_float() : $GLOBALS['StartTime']; $EndTime = microtime_float(); $RunTime = $EndTime - $StartTime; return $RunTime; }
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; }
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; } }
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; } }
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}"); } }
/** * 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; }
/** * * @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(); }
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; }
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(); }
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)); }
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; }
function finaliza_request() { // Fexando conex?o com o banco de dados: global $db, $smarty, $starttime, $db_time, $db_stats; $db->fechaConexao(); $totaltime = microtime_float() - $starttime; $smarty->assign("total_time", $totaltime); $smarty->assign("db_time", $db_time); $smarty->assign("real_time", $totaltime - $db_time); $smarty->assign("db_stats", $db_stats); $smarty->display("esqueleto.tpl"); die; }
public function SetPanelSettings() { // Show "All prices are in [currency code]" $currency = GetCurrencyById($GLOBALS['CurrentCurrency']); if (is_array($currency) && $currency['currencycode']) { $GLOBALS['AllPricesAreInCurrency'] = sprintf(GetLang('AllPricesAreInCurrency'), isc_html_escape($currency['currencyname']), isc_html_escape($currency['currencycode'])); } if (GetConfig('DebugMode') == 1) { $end_time = microtime_float(); $GLOBALS['ScriptTime'] = number_format($end_time - ISC_START_TIME, 4); $GLOBALS['QueryCount'] = $GLOBALS['ISC_CLASS_DB']->NumQueries; if (function_exists('memory_get_peak_usage')) { $GLOBALS['MemoryPeak'] = "Memory usage peaked at " . NiceSize(memory_get_peak_usage(true)); } else { $GLOBALS['MemoryPeak'] = ''; } if (isset($_REQUEST['debug'])) { $GLOBALS['QueryList'] = "<ol class='QueryList' style='font-size: 13px;'>\n"; foreach ($GLOBALS['ISC_CLASS_DB']->QueryList as $query) { $GLOBALS['QueryList'] .= "<li style='line-height: 1.4; margin-bottom: 4px;'>" . isc_html_escape($query['Query']) . " — <em>" . number_format($query['ExecutionTime'], 4) . "seconds</em></li>\n"; } $GLOBALS['QueryList'] .= "</ol>"; } $GLOBALS['DebugDetails'] = "<p>Page built in " . $GLOBALS['ScriptTime'] . "s with " . $GLOBALS['QueryCount'] . " queries. " . $GLOBALS['MemoryPeak'] . "</p>"; } else { $GLOBALS['DebugDetails'] = ''; } // Do we have any live chat service code to show in the footer $modules = GetConfig('LiveChatModules'); if (!empty($modules)) { $liveChatClass = GetClass('ISC_LIVECHAT'); $GLOBALS['LiveChatFooterCode'] = $liveChatClass->GetPageTrackingCode('footer'); } // Load our whitelabel file for the front end require_once ISC_BASE_PATH . '/includes/whitelabel.php'; // Load the configuration file for this template $poweredBy = 0; require_once ISC_BASE_PATH . '/templates/' . GetConfig('template') . '/config.php'; if (isset($GLOBALS['TPL_CFG']['PoweredBy'])) { if (!isset($GLOBALS['ISC_CFG']['TemplatePoweredByLines'][$GLOBALS['TPL_CFG']['PoweredBy']])) { $GLOBALS['TPL_CFG']['PoweredBy'] = 0; } $poweredBy = $GLOBALS['TPL_CFG']['PoweredBy']; } // Showing the powered by? $GLOBALS['PoweredBy'] = ''; if ($GLOBALS['ISC_CFG']['DisableFrontEndPoweredBy'] == false && isset($GLOBALS['ISC_CFG']['TemplatePoweredByLines'][$poweredBy])) { $GLOBALS['PoweredBy'] = $GLOBALS['ISC_CFG']['TemplatePoweredByLines'][$poweredBy]; } }
function draw() { global $__utime_start; global $__debug_array; debug($this, "Execution time (until debugWidget) :" . round(microtime_float() - $__utime_start, 3) . "s"); $arr =& $__debug_array; $out .= "<table class=\"debug\"><tr><td class=\"debug_header\">Object</td><td class=\"debug_header\">Message</td></tr>"; for ($i = 0; $i < count($arr); $i++) { $out .= "<tr><td class=\"debug_object\"><b>" . $arr[$i]["object"] . "</b></td><td class=\"debug_message\">" . $arr[$i]["message"] . "</td></tr>"; } $out .= "</table>"; $box = new Box("ooCommon NG Debug"); $box->addWidget(html::write($out)); return $box->draw(); }
function bottom($start) { ?> </div> </div> <div id="footer"></div> <p>Script Execution Time: <?php echo round(microtime_float() - $start, 3); ?> seconds</p> </div> </body> </html> <?php }
/** * Check a FileServe link. * * See the FileServe API documentation for details: * http://app.fileserve.com/api/download/ * * @param string $url File URL. * @return array */ function check($url) { $result = array('final_url' => $url, 'redirect_count' => 0, 'timeout' => false, 'broken' => false, 'log' => sprintf("<em>(%s)</em>\n\n", __('Using FileServe API', 'broken-link-checker')), 'result_hash' => '', 'status_code' => '', 'status_text' => ''); //We know the URL will match because ModuleCheckerUrlPattern matched. preg_match('@^http://(?:www\\.)?fileserve\\.com/file/([\\w\\d]+?)(?:/|$|[?#])@i', $url, $matches); $file_id = $matches[1]; $conf = blc_get_configuration(); $args = array('timeout' => $conf->options['timeout'], 'body' => array('shorten' => $file_id)); $start = microtime_float(); $response = wp_remote_post($this->fileserve_api_url, $args); $result['request_duration'] = microtime_float() - $start; $error_code = 0; if (is_wp_error($response)) { $result['log'] .= "Error : " . $response->get_error_message(); $result['broken'] = true; $result['http_code'] = 0; } else { $result['http_code'] = intval($response['response']['code']); if ($result['http_code'] == 200) { //In this case, the HTTP code returned by is not meaningful in itself, //so we won't store it or display it to the user. $result['http_code'] = 0; $json = json_decode($response['body'], false); if (isset($json->error_code)) { $error_code = intval($json->error_code); } $failure_codes = array(310 => 'Invalid request', 403 => 'Not premium', 404 => 'Invalid link', 601 => 'Limited free download', 602 => 'Number of concurrent download exceeded', 603 => 'Too many invalid capcha', 605 => 'Expired premium', 606 => 'Invalid file ID', 607 => 'File not available', 608 => 'File not available'); if (array_key_exists($error_code, $failure_codes)) { $result['broken'] = true; $result['status_code'] = BLC_LINK_STATUS_ERROR; $result['status_text'] = __('Not Found', 'broken-link-checker'); $result['log'] .= sprintf(__('FileServe : %d %s', 'broken-link-checker') . "\n", $error_code, $failure_codes[$error_code]); } else { $result['status_code'] = BLC_LINK_STATUS_OK; $result['status_text'] = _x('OK', 'link status', 'broken-link-checker'); } //$result['log'] .= "API response :\n" . htmlspecialchars(print_r((array)$json, true)); $result['log'] .= "API response :\n<code>" . htmlspecialchars($response['body']) . "</code>\n"; } else { //Unexpected error. $result['log'] .= $response['body']; $result['broken'] = true; } } //Generate the result hash (used for detecting false positives) $result['result_hash'] = implode('|', array('fileserve', $result['http_code'], $result['broken'] ? 'broken' : '0', $result['timeout'] ? 'timeout' : '0', $error_code)); return $result; }
function wpsc_debug_start_subtimer($name, $action, $loop = false) { global $wpsc_debug_sections, $loop_debug_increment; if ($loop === true) { if ($action == 'start') { $loop_debug_increment[$name]++; $wpsc_debug_sections[$name . $loop_debug_increment[$name]][$action] = microtime_float(); } else { if ($action == 'stop') { $wpsc_debug_sections[$name . $loop_debug_increment[$name]][$action] = microtime_float(); } } } else { $wpsc_debug_sections[$name][$action] = microtime_float(); } }
function query($query, $quick = false) { $t = microtime_float(); $this->quick = $quick; $this->query = $query; $this->sqlStr[] = $this->query; $this->quick ? $queryFunc = "mysql_unbuffered_query" : ($queryFunc = "mysql_query"); $this->result = @$queryFunc($this->query, $this->conn); $this->sQueries++; $took = microtime_float() - $t; $this->logs[] = array($query, $took); if (!$this->result) { $this->dbError(); } return $this->result; }
/** * Class loader action loads the class from which we will get the remote method */ function classLoaderAction(&$amfbody) { if (!$amfbody->noExec) { // change to the gateway.php script directory // now change to the directory of the classpath. Possible relative to gateway.php $dirname = dirname($amfbody->classPath); if (is_dir($dirname)) { chdir($dirname); } else { $ex = new MessageException(E_USER_ERROR, "The classpath folder {" . $amfbody->classPath . "} does not exist. You probably misplaced your service.", __FILE__, __LINE__, "AMFPHP_CLASSPATH_NOT_FOUND"); MessageException::throwException($amfbody, $ex); return false; } $fileExists = @file_exists(basename($amfbody->classPath)); // see if the file exists if (!$fileExists) { $ex = new MessageException(E_USER_ERROR, "The class {" . $amfbody->className . "} could not be found under the class path {" . $amfbody->classPath . "}", __FILE__, __LINE__, "AMFPHP_FILE_NOT_FOUND"); MessageException::throwException($amfbody, $ex); return false; } global $amfphp; $time = microtime_float(); $fileIncluded = Executive::includeClass($amfbody, "./" . basename($amfbody->classPath)); $amfphp['includeTime'] += microtime_float() - $time; if (!$fileIncluded) { $ex = new MessageException(E_USER_ERROR, "The class file {" . $amfbody->className . "} exists but could not be included. The file may have syntax errors, or includes at the top of the file cannot be resolved.", __FILE__, __LINE__, "AMFPHP_FILE_NOT_INCLUDED"); MessageException::throwException($amfbody, $ex); return false; } if (!class_exists($amfbody->className)) { // Just make sure the class name is the same as the file name $ex = new MessageException(E_USER_ERROR, "The file {" . $amfbody->className . ".php} exists and was included correctly but a class by that name could not be found in that file. Perhaps the class is misnamed.", __FILE__, __LINE__, "AMFPHP_CLASS_NOT_FOUND"); MessageException::throwException($amfbody, $ex); return false; } //Let executive handle building the class //The executive can handle making exceptions and all that, that's why $classConstruct = Executive::buildClass($amfbody, $amfbody->className); if ($classConstruct !== '__amfphp_error') { $amfbody->setClassConstruct($classConstruct); } else { return false; } } return true; }
function output_page($page_title = "") { global $smarty, $settings, $time_start; $smarty->assign("page_content", $this->get_page()); $smarty->assign("page_title", "{$settings['site']['long_name']} - {$page_title}"); $smarty->assign("header_data", $this->get_header_data()); $smarty->assign("page_footer", implode("\n", $this->footer_objects) . "\n#RENDERTIME#"); $smarty->load_filter('output', 'rewrite_urls'); if ($type == true && file_exists(path::file("templates") . "{$settings['theme']}/main_{$type}.html")) { $output = trim($smarty->fetch("{$settings['theme']}/main_{$type}.html")); } else { $output = trim($smarty->fetch("{$settings['theme']}/main.html")); } $time_end = microtime_float(); $time = round($time_end - $time_start, 4); echo str_replace("#RENDERTIME#", "[Render Time: {$time}s]", $output); }
function ping($host, $port) { $errno; $errstr; $time_start = microtime_float(); $ip = gethostbyname($host); $fp = fsockopen($host, $port, $errno, $errstr, 1); if (!$fp) { return 'Request timed out.' . "\r\n"; } $get = "GET / HTTP/1.1\r\nHost:" . $host . "\r\nConnection: Close\r\n\r\n"; @fputs($fp, $get); @fclose($fp); $time_end = microtime_float(); $time = $time_end - $time_start; $time = ceil($time * 1000); return 'Reply from ' . $ip . ': time=' . $time . 'ms'; }
public function GetOutput($Db) { $Bookmarks = new eveApiBookmarks($Db); $full_url = FULL_URL; // TODO $time_start = microtime_float(); if (!$Bookmarks->fetch(CHAR_ID, USER_ID, API_KEY, CORP_MODE)) { $this->Output = $Bookmarks->Error; return false; } $time_end = microtime_float(); $time_api = $time_end - $time_start; $this->Updated = APITime($Bookmarks); $this->Title = "Bookmarks for " . USER_NAME; $xpandall = isset($_GET['xpandall']); if (count($Bookmarks->BookmarksByLocation) > 0) { $this->Output .= ""; $this->Output .= count($Bookmarks->Bookmarks) . " items total in " . count($Bookmarks->BookmarksByLocation) . " locations<br>"; if (!$xpandall) { $this->Output .= "<a href=\"{$full_url}&view=assets&xpandall\">Expand all entries</a><br>"; } else { $this->Output .= "<a href=\"{$full_url}&view=assets\">Collapse all entries</a><br>"; } $this->Output .= "<br><table class='fancy2'>"; foreach ($Bookmarks->BookmarksByLocation as $location => $items) { $system = $Db->getLocationNameFromId($location); $this->Output .= "<tr><td style='cursor:pointer;' onclick=\"return toggle_visibility('l{$location}');\"><a href=\"#\" onclick=\"return false\">"; $this->Output .= "<b>" . $system . "</b></a></td><td align=right><b>" . count($items) . " item" . (count($items) == 1 ? "" : "s") . "</b> <br></td></tr>"; $this->Output .= "<tr><td colspan=2><div id=\"l{$location}\" style=\"" . ($xpandall ? "display:block;" : "display:none;") . "\"><br>\n"; foreach ($items as $i => $bookmark) { if ($Bookmarks->Bookmarks[$bookmark]['creatorID'] == 0) { $this->Output .= $Bookmarks->Bookmarks[$bookmark]['bookmarkID'] . " "; } $this->Output .= $Bookmarks->Bookmarks[$bookmark]['memo'] . "<br>"; } $this->Output .= "<br></div></td></tr>\n"; } $this->Output .= "</table>"; } else { $this->Output .= "<br>Character has no Bookmarks.<br>"; } $this->Times = getPageTimes($Db, $time_api, microtime_float() - $time_start); return true; }
public function check_plan() { $time_start = microtime_float(); $max = 1; $con = ' AND publish_time<=' . TIMENOW . ' ORDER BY publish_time LIMIT ' . $max; $plan = $this->obj->get_plan_by_con($con); if (!$plan) { echo "NO_PLAN"; exit; } foreach ($plan as $v) { $this->show($v); } $time_end = microtime_float(); $alltime = $time_end - $time_start; if ($alltime >= 10) { //file_put_contents(CUR_CONF_PATH . 'cache/10.txt', var_export($plan, true) . $alltime . "\n\n", FILE_APPEND); } }
function jp($params, $type = "") { $startTime = microtime_float(); $db = $this->model("mvc_dog"); $page = intval(f('page')); $from = $page * 10; $keyw = f("key") ? f("key") : $params[0]; $this->sv('keyw', $keyw); if ($keyw) { $table = "word_urljp_rich"; if ($type == "cn") { $table = "se_word_url"; } $key = get_search_keyword($keyw); $ra_key = explode(',', $key); $all = $db->rows("select url as link,sum(link_num)*(pow(count(*),3)+1) as num \r\n\t\t\tfrom {$table} \r\n\t\t\twhere word in(" . $key . ") \r\n\t\t\tgroup by url order by num desc limit {$from},11"); foreach ($all as &$one) { if ($type == "cn") { $url_info = $db->rows("select distinct(word) as aword from se_word_url where url=? limit 10", array($one["link"])); $one["title"] = $keyw; $ke = array(); foreach ($url_info as $j) { $ke[] = $j["aword"]; } $one["description"] = join(",", $ke); } else { $url_info = $db->row("select * from url_info where url=? limit 1", array($one["link"])); $one["title"] = $keyw; $one["description"] = "{$url_info['keyw']}\n{$url_info['chaset']}"; } $rhurl = parse_url($one['link']); $one['host'] = $rhurl['host']; } if (count($all) > 10) { $this->sv('has_next', 1); array_pop($all); } $this->sv("result", $all); $this->sv("page", $page); } $consumeTime = microtime_float() - $startTime; $this->sv("consumeTime", $consumeTime); }
function elapsed($start_time = null) { /*** * Return the duration since the start time in * milliseconds. * If no start time is provided, it'll try to use the global * variable $start_script_timer * * @param float $start_time in unix epoch. See http://us1.php.net/microtime ***/ if (!is_numeric($start_time)) { global $start_script_timer; if (is_numeric($start_script_timer)) { $start_time = $start_script_timer; } else { return false; } } return 1000 * (microtime_float() - (double) $start_time); }