Time of generation of a script is calculated more correctly
This commit is contained in:
parent
d584783a63
commit
8e204086e7
10 changed files with 23 additions and 35 deletions
10
footer.php
10
footer.php
|
@ -145,13 +145,16 @@ else if ($footer_style == 'viewtopic')
|
|||
</div>
|
||||
<?php
|
||||
|
||||
// End the transaction
|
||||
$db->end_transaction();
|
||||
|
||||
// Display debug info (if enabled/defined)
|
||||
if (defined('PUN_DEBUG'))
|
||||
{
|
||||
echo '<p id="debugtime">[ ';
|
||||
|
||||
// Calculate script generation time
|
||||
$time_diff = sprintf('%.3f', get_microtime() - $pun_start);
|
||||
$time_diff = sprintf('%.3f', microtime(true) - (empty($_SERVER['REQUEST_TIME_FLOAT']) ? $pun_start : $_SERVER['REQUEST_TIME_FLOAT']));
|
||||
echo sprintf($lang_common['Querytime'], $time_diff, $db->get_num_queries());
|
||||
|
||||
if (function_exists('memory_get_usage'))
|
||||
|
@ -165,10 +168,6 @@ if (defined('PUN_DEBUG'))
|
|||
echo ' ]</p>'."\n";
|
||||
}
|
||||
|
||||
|
||||
// End the transaction
|
||||
$db->end_transaction();
|
||||
|
||||
// Display executed queries (if enabled)
|
||||
if (defined('PUN_SHOW_QUERIES'))
|
||||
display_saved_queries();
|
||||
|
@ -178,7 +177,6 @@ $tpl_main = str_replace('<pun_footer>', $tpl_temp, $tpl_main);
|
|||
ob_end_clean();
|
||||
// END SUBST - <pun_footer>
|
||||
|
||||
|
||||
// Close the db connection (and free up any result data)
|
||||
$db->close();
|
||||
|
||||
|
|
|
@ -49,6 +49,9 @@ if (!defined('PUN'))
|
|||
exit;
|
||||
}
|
||||
|
||||
// Record the start time (will be used to calculate the generation time for the page)
|
||||
$pun_start = microtime(true);
|
||||
|
||||
// Load the functions script
|
||||
require PUN_ROOT.'include/functions.php';
|
||||
|
||||
|
@ -67,9 +70,6 @@ forum_unregister_globals();
|
|||
// The addon manager is responsible for storing the hook listeners and communicating with the addons
|
||||
$flux_addons = new flux_addon_manager();
|
||||
|
||||
// Record the start time (will be used to calculate the generation time for the page)
|
||||
$pun_start = get_microtime();
|
||||
|
||||
// Make sure PHP reports all errors except E_NOTICE. FluxBB supports E_ALL, but a lot of scripts it may interact with, do not
|
||||
//error_reporting(E_ALL ^ E_NOTICE);
|
||||
error_reporting(E_ALL);
|
||||
|
|
|
@ -74,7 +74,7 @@ class DBLayer
|
|||
function query($sql, $unbuffered = false)
|
||||
{
|
||||
if (defined('PUN_SHOW_QUERIES'))
|
||||
$q_start = get_microtime();
|
||||
$q_start = microtime(true);
|
||||
|
||||
if ($unbuffered)
|
||||
$this->query_result = @mysql_unbuffered_query($sql, $this->link_id);
|
||||
|
@ -84,7 +84,7 @@ class DBLayer
|
|||
if ($this->query_result)
|
||||
{
|
||||
if (defined('PUN_SHOW_QUERIES'))
|
||||
$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
|
||||
$this->saved_queries[] = array($sql, sprintf('%.5f', microtime(true) - $q_start));
|
||||
|
||||
++$this->num_queries;
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class DBLayer
|
|||
function query($sql, $unbuffered = false)
|
||||
{
|
||||
if (defined('PUN_SHOW_QUERIES'))
|
||||
$q_start = get_microtime();
|
||||
$q_start = microtime(true);
|
||||
|
||||
if ($unbuffered)
|
||||
$this->query_result = @mysql_unbuffered_query($sql, $this->link_id);
|
||||
|
@ -91,7 +91,7 @@ class DBLayer
|
|||
if ($this->query_result)
|
||||
{
|
||||
if (defined('PUN_SHOW_QUERIES'))
|
||||
$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
|
||||
$this->saved_queries[] = array($sql, sprintf('%.5f', microtime(true) - $q_start));
|
||||
|
||||
++$this->num_queries;
|
||||
|
||||
|
|
|
@ -76,14 +76,14 @@ class DBLayer
|
|||
function query($sql, $unbuffered = false)
|
||||
{
|
||||
if (defined('PUN_SHOW_QUERIES'))
|
||||
$q_start = get_microtime();
|
||||
$q_start = microtime(true);
|
||||
|
||||
$this->query_result = @mysqli_query($this->link_id, $sql);
|
||||
|
||||
if ($this->query_result)
|
||||
{
|
||||
if (defined('PUN_SHOW_QUERIES'))
|
||||
$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
|
||||
$this->saved_queries[] = array($sql, sprintf('%.5f', microtime(true) - $q_start));
|
||||
|
||||
++$this->num_queries;
|
||||
|
||||
|
|
|
@ -83,14 +83,14 @@ class DBLayer
|
|||
function query($sql, $unbuffered = false)
|
||||
{
|
||||
if (defined('PUN_SHOW_QUERIES'))
|
||||
$q_start = get_microtime();
|
||||
$q_start = microtime(true);
|
||||
|
||||
$this->query_result = @mysqli_query($this->link_id, $sql);
|
||||
|
||||
if ($this->query_result)
|
||||
{
|
||||
if (defined('PUN_SHOW_QUERIES'))
|
||||
$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
|
||||
$this->saved_queries[] = array($sql, sprintf('%.5f', microtime(true) - $q_start));
|
||||
|
||||
++$this->num_queries;
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ class DBLayer
|
|||
$sql = preg_replace('%LIMIT ([0-9]+),([ 0-9]+)%', 'LIMIT \\2 OFFSET \\1', $sql);
|
||||
|
||||
if (defined('PUN_SHOW_QUERIES'))
|
||||
$q_start = get_microtime();
|
||||
$q_start = microtime(true);
|
||||
|
||||
@pg_send_query($this->link_id, $sql);
|
||||
$this->query_result = @pg_get_result($this->link_id);
|
||||
|
@ -117,7 +117,7 @@ class DBLayer
|
|||
if (pg_result_status($this->query_result) != PGSQL_FATAL_ERROR)
|
||||
{
|
||||
if (defined('PUN_SHOW_QUERIES'))
|
||||
$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
|
||||
$this->saved_queries[] = array($sql, sprintf('%.5f', microtime(true) - $q_start));
|
||||
|
||||
++$this->num_queries;
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ class DBLayer
|
|||
function query($sql, $unbuffered = false)
|
||||
{
|
||||
if (defined('PUN_SHOW_QUERIES'))
|
||||
$q_start = get_microtime();
|
||||
$q_start = microtime(true);
|
||||
|
||||
if ($unbuffered)
|
||||
$this->query_result = @sqlite_unbuffered_query($this->link_id, $sql);
|
||||
|
@ -105,7 +105,7 @@ class DBLayer
|
|||
if ($this->query_result)
|
||||
{
|
||||
if (defined('PUN_SHOW_QUERIES'))
|
||||
$this->saved_queries[] = array($sql, sprintf('%.5f', get_microtime() - $q_start));
|
||||
$this->saved_queries[] = array($sql, sprintf('%.5f', microtime(true) - $q_start));
|
||||
|
||||
++$this->num_queries;
|
||||
|
||||
|
|
|
@ -7,16 +7,6 @@
|
|||
*/
|
||||
|
||||
|
||||
|
||||
//
|
||||
// Return current timestamp (with microseconds) as a float
|
||||
//
|
||||
function get_microtime()
|
||||
{
|
||||
list($usec, $sec) = explode(' ', microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
|
||||
//
|
||||
// Cookie stuff!
|
||||
//
|
||||
|
|
|
@ -111,12 +111,12 @@ function secure_random_bytes($len = 10)
|
|||
// Measure the time that the operations will take on average
|
||||
for ($i = 0; $i < 3; $i++)
|
||||
{
|
||||
$c1 = get_microtime();
|
||||
$c1 = microtime(true);
|
||||
$var = sha1(mt_rand());
|
||||
for ($j = 0; $j < 50; $j++) {
|
||||
$var = sha1($var);
|
||||
}
|
||||
$c2 = get_microtime();
|
||||
$c2 = microtime(true);
|
||||
$entropy .= $c1 . $c2;
|
||||
}
|
||||
|
||||
|
@ -129,12 +129,12 @@ function secure_random_bytes($len = 10)
|
|||
$iter = $bytes * (int) (ceil(8 / $bits_per_round));
|
||||
for ($i = 0; $i < $iter; $i++)
|
||||
{
|
||||
$c1 = get_microtime();
|
||||
$c1 = microtime(true);
|
||||
$var = sha1(mt_rand());
|
||||
for ($j = 0; $j < $rounds; $j++) {
|
||||
$var = sha1($var);
|
||||
}
|
||||
$c2 = get_microtime();
|
||||
$c2 = microtime(true);
|
||||
$entropy .= $c1 . $c2;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue