本文整理汇总了PHP中get_num_queries函数的典型用法代码示例。如果您正苦于以下问题:PHP get_num_queries函数的具体用法?PHP get_num_queries怎么用?PHP get_num_queries使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_num_queries函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: memory
function memory()
{
if (current_user_can('level_10')) {
global $wpdb;
echo '<span style="text-align:center;display:block;">';
$timer = timer_stop();
echo round(memory_get_peak_usage() / 1048576, 2) . 'M ' . get_num_queries() . ' queries in ' . $timer . ' Seconds.</span>';
}
}
示例2: wb_do
function wb_do()
{
printf(__('SQL requests:%d. Generation time:%s sec. Memory consumption:', WB_CHANGE_EMAIL_SLUG), get_num_queries(), timer_stop(0, 3));
if (function_exists('memory_get_usage')) {
echo round(memory_get_usage() / 1024 / 1024, 2) . ' mb ';
}
}
示例3: addStatistics
/**
*
* Adds a piece of commented out code to the source code of each webpage that shows many queries occur, time taken and memory used
*
* @since 4.1.1
*
* @param type $var statisitcs.
* @param array $args {
* @type type $var statistics : var to store the the queries and echo it out to the page
* }
*/
function addStatistics()
{
$statistics = sprintf('%d queries in %.3f seconds, using %.2fMB memory', get_num_queries(), timer_stop(0, 3), memory_get_peak_usage() / 1024 / 1024);
if (current_user_can('manage_options')) {
echo "<!-- {$statistics} -->";
}
}
示例4: info_unqprfx_code
function info_unqprfx_code($atts, $content = null)
{
// add info to source code
$useful_info = sprintf('%d q; %.2f sec; %.2f MB;', get_num_queries(), timer_stop(0, 3), memory_get_peak_usage() / 1024 / 1024);
echo "\n" . '<!-- info plugin v.2.3 wordpress.org/plugins/info/ -->' . "\n";
echo '<!-- ========== ' . $useful_info . ' ========== -->' . "\n";
}
示例5: lt_store_timer_data
function lt_store_timer_data()
{
global $wpdb;
$table_name = lt_get_table_name();
$lt_data = array('longdatetime' => date('Y-m-d H:i:s', time()), 'qcount' => get_num_queries(), 'qtime' => timer_stop(0, 3), 'qpage' => "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 'useragent' => $_SERVER['HTTP_USER_AGENT']);
$wpdb->insert($table_name, $lt_data);
}
示例6: ajax
public function ajax()
{
$apiArgs = isset($_GET["apiArgs"]) ? $_GET["apiArgs"] : array();
if (!$apiArgs) {
wp_send_json_error(array("error" => "MISSING_APIARGS"));
exit;
}
if (empty($apiArgs["since_id"]) || !is_numeric($apiArgs["since_id"])) {
wp_send_json_error(array("error" => "MISSING_SINCE_ID"));
exit;
}
// $since_id = isset( $_GET["since_id"] ) ? absint($_GET["since_id"]) : null;
$logQueryArgs = $apiArgs;
$logQuery = new SimpleHistoryLogQuery();
$answer = $logQuery->query($logQueryArgs);
// Use our own repsonse array instead of $answer to keep size down
$json_data = array();
$numNewRows = isset($answer["total_row_count"]) ? $answer["total_row_count"] : 0;
$json_data["num_new_rows"] = $numNewRows;
$json_data["num_mysql_queries"] = get_num_queries();
if ($numNewRows) {
// We have new rows
// Append strings
$textRowsFound = sprintf(_n('1 new event', '%d new events', $numNewRows, 'simple-history'), $numNewRows);
$json_data["strings"] = array("newRowsFound" => $textRowsFound);
}
wp_send_json_success($json_data);
}
示例7: gdptStats
function gdptStats()
{
if (function_exists("memory_get_usage")) {
$this->memory = gdFunctionsGDPT::size_format(memory_get_usage());
}
$this->queries = get_num_queries();
$this->timer = timer_stop(1);
}
示例8: performance
function performance()
{
$visible = false;
if (current_user_can('manage_options')) {
$visible = true;
}
$stat = sprintf('%d queries in %.3f seconds, using %.2fMB memory', get_num_queries(), timer_stop(0, 3), memory_get_peak_usage() / 1024 / 1024);
echo $visible ? '<div id="performance">' . $stat . '</div>' : "<!-- {$stat} -->";
}
示例9: panel_template
private function panel_template()
{
/**
* action 'redux/{opt_name}/panel/before'
*/
do_action("redux/{$this->parent->args['opt_name']}/panel/before");
echo '<div class="wrap"><h2></h2></div>';
// Stupid hack for Wordpress alerts and warnings
echo '<div class="clear"></div>';
echo '<div class="wrap">';
// Do we support JS?
echo '<noscript><div class="no-js">' . __('Warning- This options panel will not work properly without javascript!', 'redux-framework') . '</div></noscript>';
// Security is vital!
echo '<input type="hidden" id="ajaxsecurity" name="security" value="' . wp_create_nonce('redux_ajax_nonce') . '" />';
/**
* action 'redux-page-before-form-{opt_name}'
*
* @deprecated
*/
do_action("redux-page-before-form-{$this->parent->args['opt_name']}");
// Remove
/**
* action 'redux/page/{opt_name}/form/before'
*
* @param object $this ReduxFramework
*/
do_action("redux/page/{$this->parent->args['opt_name']}/form/before", $this);
$this->get_template('layout.tpl.php');
/**
* action 'redux-page-after-form-{opt_name}'
*
* @deprecated
*/
do_action("redux-page-after-form-{$this->parent->args['opt_name']}");
// REMOVE
/**
* action 'redux/page/{opt_name}/form/after'
*
* @param object $this ReduxFramework
*/
do_action("redux/page/{$this->parent->args['opt_name']}/form/after", $this);
echo '<div class="clear"></div>';
echo '</div><!--wrap-->';
if ($this->parent->args['dev_mode'] == true) {
if (current_user_can('administrator')) {
global $wpdb;
echo "<br /><pre>";
print_r($wpdb->queries);
echo "</pre>";
}
echo '<br /><div class="redux-timer">' . get_num_queries() . ' queries in ' . timer_stop(0) . ' seconds<br/>Redux is currently set to developer mode.</div>';
}
/**
* action 'redux/{opt_name}/panel/after'
*/
do_action("redux/{$this->parent->args['opt_name']}/panel/after");
}
示例10: basic_performance
function basic_performance()
{
global $pl_start_time, $pl_start_mem, $pl_perform;
$pl_perform['memory'] = array('num' => round((memory_get_usage() - $pl_start_mem) / (1024 * 1024), 3), 'label' => 'MB', 'title' => __('Editor Memory', 'pagelines'), 'info' => __('Amount of memory used by the DMS editor in MB during this page load.', 'pagelines'));
$pl_perform['queries'] = array('num' => get_num_queries(), 'label' => __('Queries', 'pagelines'), 'title' => __('Total Queries', 'pagelines'), 'info' => __('The number of database queries during the WordPress/Editor execution.', 'pagelines'));
$pl_perform['total_time'] = array('num' => timer_stop(0), 'label' => __('Seconds', 'pagelines'), 'title' => __('Total Time', 'pagelines'), 'info' => __('Total time to render this page including WordPress and DMS editor.', 'pagelines'));
$pl_perform['time'] = array('num' => round(microtime(TRUE) - $pl_start_time, 3), 'label' => __('Seconds', 'pagelines'), 'title' => __('Editor Time', 'pagelines'), 'info' => __('Amount of time it took to load this page once DMS had started.', 'pagelines'));
return $pl_perform;
}
示例11: _getPageLoadStats
private function _getPageLoadStats()
{
$_nSeconds = timer_stop(0);
$_nQueryCount = get_num_queries();
$_nMemoryUsage = round($this->_convertBytesToHR(memory_get_usage()), 2);
$_nMemoryPeakUsage = round($this->_convertBytesToHR(memory_get_peak_usage()), 2);
$_nMemoryLimit = round($this->_convertBytesToHR($this->_convertToNumber(WP_MEMORY_LIMIT)), 2);
$_sInitialMemoryUsage = round($this->_convertBytesToHR($this->_nInitialMemoryUsage), 2);
return "<div id='admin-page-framework-page-load-stats'>" . "<ul>" . "<li>" . sprintf($this->oMsg->get('queries_in_seconds'), $_nQueryCount, $_nSeconds) . "</li>" . "<li>" . sprintf($this->oMsg->get('out_of_x_memory_used'), $_nMemoryUsage, $_nMemoryLimit, round($_nMemoryUsage / $_nMemoryLimit, 2) * 100 . '%') . "</li>" . "<li>" . sprintf($this->oMsg->get('peak_memory_usage'), $_nMemoryPeakUsage) . "</li>" . "<li>" . sprintf($this->oMsg->get('initial_memory_usage'), $_sInitialMemoryUsage) . "</li>" . "</ul>" . "</div>";
}
示例12: spdebug_end_stats
function spdebug_end_stats()
{
global $spdebug_stats, $spdebug_queries;
$mtime = explode(' ', microtime());
$time_end = $mtime[1] + $mtime[0];
$spdebug_stats['end_time'] = $time_end;
$spdebug_stats['total_time'] = $spdebug_stats['end_time'] - $spdebug_stats['start_time'];
$spdebug_stats['end_query'] = get_num_queries();
$spdebug_stats['total_query'] = $spdebug_stats['end_query'] - $spdebug_stats['start_query'];
$spdebug_queries = false;
}
示例13: AfterExecute
protected function AfterExecute()
{
$this->exec_info['Time'] = microtime(true) - $this->exec_info['_Time'];
$this->exec_info['Mem'] = memory_get_usage() - $this->exec_info['_Mem'];
if ($this->exec_info['Time'] < 0.001) {
$this->exec_info['Time'] = number_format($this->exec_info['Time'] * 1000, 3) . 'ms';
} else {
$this->exec_info['Time'] = number_format($this->exec_info['Time'], 3) . 's';
}
$this->exec_info['Mem'] = size_format($this->exec_info['Mem']);
$this->exec_info['Queries'] = get_num_queries();
}
示例14: _replyToGetPageLoadInfo
public function _replyToGetPageLoadInfo($sFooterHTML)
{
if (self::$_bLoadedPageLoadInfo) {
return;
}
self::$_bLoadedPageLoadInfo = true;
$_nSeconds = timer_stop(0);
$_nQueryCount = get_num_queries();
$_nMemoryUsage = round($this->_convertBytesToHR(memory_get_usage()), 2);
$_nMemoryPeakUsage = round($this->_convertBytesToHR(memory_get_peak_usage()), 2);
$_nMemoryLimit = round($this->_convertBytesToHR($this->_convertToNumber(WP_MEMORY_LIMIT)), 2);
$_sInitialMemoryUsage = round($this->_convertBytesToHR($this->_nInitialMemoryUsage), 2);
return $sFooterHTML . "<div id='admin-page-framework-page-load-stats'>" . "<ul>" . "<li>" . sprintf($this->oMsg->get('queries_in_seconds'), $_nQueryCount, $_nSeconds) . "</li>" . "<li>" . sprintf($this->oMsg->get('out_of_x_memory_used'), $_nMemoryUsage, $_nMemoryLimit, round($_nMemoryUsage / $_nMemoryLimit, 2) * 100 . '%') . "</li>" . "<li>" . sprintf($this->oMsg->get('peak_memory_usage'), $_nMemoryPeakUsage) . "</li>" . "<li>" . sprintf($this->oMsg->get('initial_memory_usage'), $_sInitialMemoryUsage) . "</li>" . "</ul>" . "</div>";
}
示例15: bp_core_print_generation_time
/**
* Print the generation time in the footer of the site.
*
* @since 1.0.0
* @deprecated 2.6.0
*/
function bp_core_print_generation_time()
{
?>
<!-- Generated in <?php
timer_stop(1);
?>
seconds. (<?php
echo get_num_queries();
?>
q) -->
<?php
}