本文整理汇总了PHP中xdebug_time_index函数的典型用法代码示例。如果您正苦于以下问题:PHP xdebug_time_index函数的具体用法?PHP xdebug_time_index怎么用?PHP xdebug_time_index使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了xdebug_time_index函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bench
public function bench(RestServer $rest)
{
$rest->getResponse()->appendResponse("It took " . round(xdebug_time_index(), 5) . " seconds\n");
$rest->getResponse()->appendResponse("Used " . round(xdebug_memory_usage() / 1024, 5) . "Kb of Memory\n");
$rest->getResponse()->appendResponse("Used at peak " . round(xdebug_peak_memory_usage() / 1024, 5) . "Kb of Memory\n");
return $rest;
}
示例2: getScriptDuration
public function getScriptDuration()
{
if (function_exists('xdebug_time_index')) {
return sprintf("%0.2f", xdebug_time_index());
} else {
return 'n/a';
}
}
示例3: benchIt
public static function benchIt()
{
if (function_exists('xdebug_time_index')) {
return xdebug_time_index();
} else {
return microtime();
}
}
示例4: onApiRespond
/**
* @param \Civi\API\Event\RespondEvent $event
* API response event.
*/
public function onApiRespond(\Civi\API\Event\RespondEvent $event)
{
$apiRequest = $event->getApiRequest();
$result = $event->getResponse();
if (function_exists('xdebug_time_index') && \CRM_Utils_Array::value('debug', $apiRequest['params']) && is_array($result)) {
$result['xdebug']['peakMemory'] = xdebug_peak_memory_usage();
$result['xdebug']['memory'] = xdebug_memory_usage();
$result['xdebug']['timeIndex'] = xdebug_time_index();
$event->setResponse($result);
}
}
示例5: assert
/**
* Add an assertion to the test
*
* @param string $label
* @param boolean $status
* @param string $filename
* @param int $line
* @throws \RuntimeException
* @return \Unitest\Result
*/
public function assert($label, $status, $filename, $line)
{
if (!function_exists('xdebug_time_index')) {
$message = "Xdebug is required to use Unitest";
throw new \RuntimeException($message, 500);
}
if (false === $status) {
++$this->failed;
}
$this->assertions[] = new Assert($label, $status, $filename, $line, xdebug_time_index());
return $this;
}
示例6: xdebugInfo
/**
* Weird little script to trigger an xdebug info box.
* I use this to test for bottlenecks before I discovered cache grind. I'll leave it in incase I need it for something.
*
* @param string $msg A message, useful for identifying a break point.
*/
function xdebugInfo ($msg = false)
{
if ($init['debug'])
{
trigger_error(
'[xdbInfo] ' . ($msg ? '<span style="color:white;background-color:#D60;">' . $msg . '</span> | ' : null) .
'
Mem: <span style="color:white;background-color:#D60;">' . Round(
(xdebug_memory_usage() / 1000), 2) . '
Kb</span>, Time: <span style="color:white;background-color:#D60;">' . str_pad(
Round(xdebug_time_index(), 4), 6, '0') . 'secs</span>', E_USER_WARNING);
}
}
示例7: doDefault
function doDefault()
{
/* {{{ 导入过滤模块,并初始化 */
importModule("Filter.Filter");
$fl = new Filter();
/* }}} */
/* {{{ 过滤测试测试文本 */
$content = "大家好.有人认识李洪志吗? 学过法轮功的吗?";
echo "<b>原语句:</b> ", $content, "<br />";
/* }}} */
/* {{{ 检测是否含有非法关键字 */
$show = $fl->isForbidden($content);
if ($show) {
echo "<br />含有非法关键字!<br /><br />";
} else {
echo "<br />没有有非法关键字!<br /><br />";
}
/* }}} */
/* {{{ 过滤文本 */
$start = xdebug_time_index();
$show = $fl->clean($content);
echo "<b>过滤后的:</b>", $show, "<br />";
echo "用时: ", xdebug_time_index() - $start, "<br />";
/* }}} */
/* {{{ 过滤文本, 指定替换的格式 */
$start = xdebug_time_index();
$show = $fl->clean($content, "×");
echo "<br /><b>指定替换内容过滤:</b> ", $show, "<br />";
echo "用时: ", xdebug_time_index() - $start, "<br />";
/* }}} */
/* {{{ 并手工指定关键字再过滤文本 */
$start = xdebug_time_index();
$fl->setKey(array('大家好'));
$show = $fl->clean($content);
echo "<br /><b>手工指定关键字过滤:</b> ", $show, "<br />";
echo "用时: ", xdebug_time_index() - $start, "<br />";
/* }}} */
/* {{{ 模糊过滤文本 */
$start = xdebug_time_index();
$ff = new Filter();
$content = "start:李 洪 志-测-试- f-!u-c=k, fuck:end";
echo "<br /><b>原语句:</b> ", $content, "<br />";
$show = $ff->fuzzyClean($content, "*", 2);
//其中2为深度,默认值,值越大清理越干净,误杀越多,消耗资源越多.
echo "<b>模糊过滤后:</b> ", $show, "<br />";
echo "用时: ", xdebug_time_index() - $start, "<br />";
/* }}} */
}
示例8: test_intersect
}
function test_intersect($list1, $list2)
{
return count(array_intersect($list1, $list2));
}
function test_order_dicto_while($list, $elem)
{
$start = 0;
$end = count($list);
while ($start < $end) {
$middle = (int) (($start + $end) / 2);
if ($list[$middle] == $elem || $list[$start] == $elem) {
return true;
}
if ($elem > $list[$middle]) {
$start = $middle + 1;
} else {
$end = $middle - 1;
}
}
return false;
}
$list1 = file('./list1.txt');
$list2 = file('./list2.txt');
$elem = 9682;
//if (test_order_dicto_while(file('./orderList.txt'), $elem)) echo "find : $elem"; else echo "not found $elem";
if (array_search($elem, file('./orderList.txt'))) {
}
//echo test_foreach($list1, $list2);
printf("duration : %f", xdebug_time_index());
示例9: printCommonFooter
/**
* Print common footer :
* conf->global->MAIN_HTML_FOOTER
* conf->global->MAIN_GOOGLE_AN_ID
* conf->global->MAIN_SHOW_TUNING_INFO or $_SERVER["MAIN_SHOW_TUNING_INFO"]
* conf->logbuffer
*
* @param string $zone 'private' (for private pages) or 'public' (for public pages)
* @return void
*/
function printCommonFooter($zone = 'private')
{
global $conf, $hookmanager;
global $micro_start_time;
if ($zone == 'private') {
print "\n" . '<!-- Common footer for private page -->' . "\n";
} else {
print "\n" . '<!-- Common footer for public page -->' . "\n";
}
if (!empty($conf->global->MAIN_HTML_FOOTER)) {
print $conf->global->MAIN_HTML_FOOTER . "\n";
}
print "\n";
if (!empty($conf->use_javascript_ajax)) {
print '<script type="text/javascript" language="javascript">jQuery(document).ready(function() {' . "\n";
print '<!-- If page_y set, we set scollbar with it -->' . "\n";
print "page_y=getParameterByName('page_y', 0);";
print "if (page_y > 0) \$('html, body').scrollTop(page_y);";
print '<!-- Set handler to add page_y param on some a href links -->' . "\n";
print 'jQuery(".reposition").click(function() {
var page_y = $(document).scrollTop();
/* alert(page_y); */
this.href=this.href+\'&page_y=\'+page_y;
});' . "\n";
print '});' . "\n";
print '</script>' . "\n";
}
// Google Analytics (need Google module)
if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) {
if (empty($conf->dol_use_jmobile)) {
print "\n";
print '<script type="text/javascript">' . "\n";
print ' var _gaq = _gaq || [];' . "\n";
print ' _gaq.push([\'_setAccount\', \'' . $conf->global->MAIN_GOOGLE_AN_ID . '\']);' . "\n";
print ' _gaq.push([\'_trackPageview\']);' . "\n";
print '' . "\n";
print ' (function() {' . "\n";
print ' var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;' . "\n";
print ' ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';' . "\n";
print ' var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);' . "\n";
print ' })();' . "\n";
print '</script>' . "\n";
}
}
// End of tuning
if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO']) || !empty($conf->global->MAIN_SHOW_TUNING_INFO)) {
print "\n" . '<script type="text/javascript">' . "\n";
print 'window.console && console.log("';
if (!empty($conf->global->MEMCACHED_SERVER)) {
print 'MEMCACHED_SERVER=' . $conf->global->MEMCACHED_SERVER . ' - ';
}
print 'MAIN_OPTIMIZE_SPEED=' . (isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off');
if ($micro_start_time) {
$micro_end_time = microtime(true);
print ' - Build time: ' . ceil(1000 * ($micro_end_time - $micro_start_time)) . ' ms';
}
if (function_exists("memory_get_usage")) {
print ' - Mem: ' . memory_get_usage();
}
if (function_exists("xdebug_memory_usage")) {
print ' - XDebug time: ' . ceil(1000 * xdebug_time_index()) . ' ms';
print ' - XDebug mem: ' . xdebug_memory_usage();
print ' - XDebug mem peak: ' . xdebug_peak_memory_usage();
}
if (function_exists("zend_loader_file_encoded")) {
print ' - Zend encoded file: ' . (zend_loader_file_encoded() ? 'yes' : 'no');
}
print '");' . "\n";
print '</script>' . "\n";
// Add Xdebug coverage of code
if (defined('XDEBUGCOVERAGE')) {
print_r(xdebug_get_code_coverage());
}
}
// If there is some logs in buffer to show
if (count($conf->logbuffer)) {
print "\n";
print "<!-- Start of log output\n";
//print '<div class="hidden">'."\n";
foreach ($conf->logbuffer as $logline) {
print $logline . "<br>\n";
}
//print '</div>'."\n";
print "End of log output -->\n";
}
$parameters = array();
$reshook = $hookmanager->executeHooks('printCommonFooter', $parameters);
// Note that $action and $object may have been modified by some hooks
}
示例10: _getTime
/**
* Get time using microtime or xdebug
*/
private function _getTime()
{
if ($this->_xdebug) {
return xdebug_time_index();
}
return microtime(false);
}
示例11: ob_start
if (file_exists($settings_file)) {
include $settings_file;
}
$BaseTemplate->template_path = SKINS_PATH;
Template::Set('MODULE_NAV_INC', $NAVBAR);
Template::Set('MODULE_HEAD_INC', $HTMLHead);
ob_start();
MainController::RunAllActions();
$page_content = ob_get_clean();
$BaseTemplate->Set('title', MainController::$page_title . ' - ' . SITE_NAME);
$BaseTemplate->Set('page_title', MainController::$page_title . ' - ' . SITE_NAME);
if (file_exists(SKINS_PATH . '/layout.tpl')) {
$BaseTemplate->Set('page_htmlhead', Template::Get('core_htmlhead.tpl', true));
$BaseTemplate->Set('page_htmlreq', Template::Get('core_htmlreq.tpl', true));
$BaseTemplate->Set('page_content', $page_content);
$BaseTemplate->ShowTemplate('layout.tpl');
} else {
# It's a template sammich!
$BaseTemplate->ShowTemplate('header.tpl');
echo $page_content;
$BaseTemplate->ShowTemplate('footer.tpl');
}
# Force connection close
DB::close();
if (Config::Get('XDEBUG_BENCHMARK')) {
$run_time = xdebug_time_index();
$memory_end = xdebug_memory_usage();
echo 'TOTAL MEMORY: ' . ($memory_end - $memory_start) . '<br />';
echo 'PEAK: ' . xdebug_peak_memory_usage() . '<br />';
echo 'RUN TIME: ' . $run_time . '<br />';
}
示例12: showDebugInfo
/**
* Display debug info gathered along the execution
*
* @return void
*/
public static function showDebugInfo()
{
global $Language;
echo '<div id="footer_debug_separator"/>';
echo '<div id="footer_debug">';
echo '<div class="alert alert-info">
<h4> Development useful information! </h4>
The section above will show you some useful information about Tuleap for development purpose.
</div>';
echo '<div id="footer_debug_content">';
$debug_compute_tile = microtime(true) - $GLOBALS['debug_time_start'];
if (function_exists('xdebug_time_index')) {
$xdebug_time_index = xdebug_time_index();
}
$query_time = 0;
foreach ($GLOBALS['DBSTORE'] as $d) {
foreach ($d['trace'] as $trace) {
$query_time += $trace[2] - $trace[1];
}
}
$purifier = Codendi_HTMLPurifier::instance();
echo '<span class="debug">' . $Language->getText('include_layout', 'query_count') . ": ";
echo $GLOBALS['DEBUG_DAO_QUERY_COUNT'] . "</span>";
$percent = (int) ($GLOBALS['DEBUG_TIME_IN_PRE'] * 100 / $debug_compute_tile);
$sql_percent = (int) ($query_time * 100 / $debug_compute_tile);
echo '<table border=1><thead><tr><th></th><th>Page generated in</th></tr></thead><tbody>';
echo '<tr><td>pre.php</td><td>' . number_format(1000 * $GLOBALS['DEBUG_TIME_IN_PRE'], 0, '.', "'") . ' ms (' . $percent . '%)</td>';
echo '<tr><td>remaining</td><td>' . number_format(1000 * ($debug_compute_tile - $GLOBALS['DEBUG_TIME_IN_PRE']), 0, '.', "'") . ' ms</td>';
echo '<tr><td><b>total</td><td><b>' . number_format(1000 * $debug_compute_tile, 0, '.', "'") . ' ms</td>';
if (function_exists('xdebug_time_index')) {
echo '<tr><td>xdebug</td><td>' . number_format(1000 * $xdebug_time_index, 0, '.', "'") . ' ms</tr>';
}
echo '<tr><td>sql</td><td>' . number_format(1000 * $query_time, 0, '.', "'") . ' ms (' . $sql_percent . '%)</tr>';
echo '</tbody></table>';
if (function_exists('xdebug_get_profiler_filename')) {
if ($file = xdebug_get_profiler_filename()) {
echo '<div>Profiler info has been written in: ' . $file . '</div>';
}
}
$hook_params = array();
EventManager::instance()->processEvent('layout_footer_debug', $hook_params);
//Display the config
// Uncomment this only if you know what you are doing. This may lead to sensitive information leakage /!\
//echo '<fieldset><legend id="footer_debug_config" class="'. Toggler::getClassname('footer_debug_config') .'">Config:</legend>';
//echo '<pre>';
//Config::dump();
//echo '</pre>';
//echo '</fieldset>';
// Display all queries used to generate the page
echo '<fieldset><legend id="footer_debug_allqueries" class="' . Toggler::getClassname('footer_debug_allqueries') . '">All queries:</legend>';
echo '<pre>';
$queries = array();
$queries_by_time_taken = array();
$i = 0;
foreach ($GLOBALS['QUERIES'] as $sql) {
$t = 0;
foreach ($GLOBALS['DBSTORE'][md5($sql)]['trace'] as $trace) {
$t += $trace[2] - $trace[1];
}
$q = array('sql' => $purifier->purify($sql), 'total time' => number_format(1000 * $t, 0, '.', "'") . ' ms');
$queries[] = $q;
$queries_by_time_taken[] = array('n°' => $i++, 't' => $t) + $q;
}
print_r($queries);
echo '</pre>';
echo '</fieldset>';
// Display all queries used to generate the page ordered by time taken
usort($queries_by_time_taken, array(__CLASS__, 'sort_queries_by_time_taken'));
echo '<fieldset><legend id="footer_debug_allqueries_time_taken" class="' . Toggler::getClassname('footer_debug_allqueries_time_taken') . '">All queries by time taken:</legend>';
echo '<table border="1" style="border-collapse:collapse" cellpadding="2" cellspacing="0">';
echo '<thead><tr><th>n°</th><th style="white-space:nowrap;">time taken</th><th>sum</th><th>sql</th></tr></thead>';
$i = 0;
$sum = 0;
foreach ($queries_by_time_taken as $q) {
echo '<tr valign="top" class="' . html_get_alt_row_color($i++) . '">';
echo '<td>' . $q['n°'] . '</td>';
echo '<td style="white-space:nowrap;">' . $q['total time'] . '</td>';
echo '<td style="white-space:nowrap;">' . number_format(1000 * ($sum += $q['t']), 0, '.', "'") . ' ms' . '</td>';
echo '<td><pre>' . $q['sql'] . '</pre></td>';
echo '</tr>';
}
echo '</table>';
echo '</fieldset>';
echo '<fieldset><legend id="footer_debug_queriespaths" class="' . Toggler::getClassname('footer_dubug_queriespaths') . '">Path of all queries:</legend>';
$max = 0;
foreach ($GLOBALS['DBSTORE'] as $d) {
foreach ($d['trace'] as $trace) {
$time_taken = 1000 * round($trace[2] - $trace[1], 3);
if ($max < $time_taken) {
$max = $time_taken;
}
}
}
$paths = array();
$time = $GLOBALS['debug_time_start'];
//.........这里部分代码省略.........
示例13: cConvertMem
echo 'End usage : ' . cConvertMem($memNow) . '<br/>';
echo 'Mem usage : ' . cConvertMem($memNow - $mem) . '<br/>';
echo 'Peak mem : ' . cConvertMem(xdebug_peak_memory_usage()) . '<br/>';
echo 'Time : ' . (xdebug_time_index() - $tm) . '<br/>';
echo 'Query : ' . $db->getTicker();
echo '</pre>';
// Log average page load
jimport('joomla.filesystem.file');
$content = JFile::read(COMMUNITY_COM_PATH . DS . 'access.log');
$params = new JParameter($content);
$today = strftime('%Y-%m-%d');
$loadTime = $params->get($today, 0);
if ($loadTime > 0) {
$loadTime = ($loadTime + (xdebug_time_index() - $tm)) / 2;
} else {
$loadTime = xdebug_time_index() - $tm;
}
$params->set($today, $loadTime);
JFile::write(COMMUNITY_COM_PATH . DS . 'access.log', $params->toString());
}
echo getJomSocialPoweredByLink();
// getTriggerCount
// $appLib = CAppPlugins::getInstance();
// echo 'Trigger count: '. $appLib->triggerCount . '<br/>';
// $time_end = microtime(true);
// $time = $time_end - $time_start;
// echo $time;
}
/**
* Entry poitn for all ajax call
*/
示例14: printCommonFooter
/**
* Print common footer :
* conf->global->MAIN_HTML_FOOTER
* conf->global->MAIN_GOOGLE_AN_ID
* DOL_TUNING
* conf->logbuffer
*
* @param string $zone 'private' (for private pages) or 'public' (for public pages)
* @return void
*/
function printCommonFooter($zone = 'private')
{
global $conf;
global $micro_start_time;
if ($zone == 'private') {
print "\n" . '<!-- Common footer for private page -->' . "\n";
} else {
print "\n" . '<!-- Common footer for public page -->' . "\n";
}
if (!empty($conf->global->MAIN_HTML_FOOTER)) {
print $conf->global->MAIN_HTML_FOOTER . "\n";
}
// Google Analytics (need Google module)
if (!empty($conf->google->enabled) && !empty($conf->global->MAIN_GOOGLE_AN_ID)) {
if (empty($conf->dol_use_jmobile)) {
print "\n";
print '<script type="text/javascript">' . "\n";
print ' var _gaq = _gaq || [];' . "\n";
print ' _gaq.push([\'_setAccount\', \'' . $conf->global->MAIN_GOOGLE_AN_ID . '\']);' . "\n";
print ' _gaq.push([\'_trackPageview\']);' . "\n";
print '' . "\n";
print ' (function() {' . "\n";
print ' var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;' . "\n";
print ' ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';' . "\n";
print ' var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);' . "\n";
print ' })();' . "\n";
print '</script>' . "\n";
}
}
// End of tuning
if (!empty($_SERVER['DOL_TUNING']) || !empty($conf->global->MAIN_SHOW_TUNING_INFO)) {
print "\n" . '<script type="text/javascript">' . "\n";
print 'window.console && console.log("';
if (!empty($conf->global->MEMCACHED_SERVER)) {
print 'MEMCACHED_SERVER=' . $conf->global->MEMCACHED_SERVER . ' - ';
}
print 'MAIN_OPTIMIZE_SPEED=' . (isset($conf->global->MAIN_OPTIMIZE_SPEED) ? $conf->global->MAIN_OPTIMIZE_SPEED : 'off');
if ($micro_start_time) {
$micro_end_time = dol_microtime_float(true);
print ' - Build time: ' . ceil(1000 * ($micro_end_time - $micro_start_time)) . ' ms';
}
if (function_exists("memory_get_usage")) {
print ' - Mem: ' . memory_get_usage();
}
if (function_exists("xdebug_memory_usage")) {
print ' - XDebug time: ' . ceil(1000 * xdebug_time_index()) . ' ms';
print ' - XDebug mem: ' . xdebug_memory_usage();
print ' - XDebug mem peak: ' . xdebug_peak_memory_usage();
}
if (function_exists("zend_loader_file_encoded")) {
print ' - Zend encoded file: ' . (zend_loader_file_encoded() ? 'yes' : 'no');
}
print '");' . "\n";
print '</script>' . "\n";
// Add Xdebug coverage of code
if (defined('XDEBUGCOVERAGE')) {
var_dump(xdebug_get_code_coverage());
}
}
// If there is some logs in buffer to show
if (count($conf->logbuffer)) {
print "\n";
print "<!-- Start of log output\n";
//print '<div class="hidden">'."\n";
foreach ($conf->logbuffer as $logline) {
print $logline . "<br>\n";
}
//print '</div>'."\n";
print "End of log output -->\n";
}
}
示例15: xdebug_time_index
<?php
$before = xdebug_time_index();
for ($i = 0; $i < 250000; $i++) {
}
$after = xdebug_time_index();
var_dump($before);
var_dump($after);
var_dump($after - $before >= 0);