Performance: Adding several variables for performance measuring.
This commit is contained in:
parent
cc9ce39e3f
commit
2c93067682
4 changed files with 61 additions and 31 deletions
6
boot.php
6
boot.php
|
@ -355,6 +355,7 @@ if(! class_exists('App')) {
|
||||||
public $identities;
|
public $identities;
|
||||||
public $is_mobile;
|
public $is_mobile;
|
||||||
public $is_tablet;
|
public $is_tablet;
|
||||||
|
public $performance = array();
|
||||||
|
|
||||||
public $nav_sel;
|
public $nav_sel;
|
||||||
|
|
||||||
|
@ -412,6 +413,11 @@ if(! class_exists('App')) {
|
||||||
|
|
||||||
date_default_timezone_set($this->timezone);
|
date_default_timezone_set($this->timezone);
|
||||||
|
|
||||||
|
$this->performance["start"] = microtime(true);
|
||||||
|
$this->performance["database"] = 0;
|
||||||
|
$this->performance["network"] = 0;
|
||||||
|
$this->performance["rendering"] = 0;
|
||||||
|
|
||||||
$this->config = array();
|
$this->config = array();
|
||||||
$this->page = array();
|
$this->page = array();
|
||||||
$this->pager= array();
|
$this->pager= array();
|
||||||
|
|
|
@ -78,18 +78,20 @@ class dba {
|
||||||
|
|
||||||
$this->error = '';
|
$this->error = '';
|
||||||
|
|
||||||
if(x($a->config,'system') && x($a->config['system'],'db_log'))
|
$stamp1 = microtime(true);
|
||||||
$stamp1 = microtime(true);
|
|
||||||
|
|
||||||
if($this->mysqli)
|
if($this->mysqli)
|
||||||
$result = @$this->db->query($sql);
|
$result = @$this->db->query($sql);
|
||||||
else
|
else
|
||||||
$result = @mysql_query($sql,$this->db);
|
$result = @mysql_query($sql,$this->db);
|
||||||
|
|
||||||
|
$stamp2 = microtime(true);
|
||||||
|
$duration = (float)($stamp2-$stamp1);
|
||||||
|
$a->performance["database"] += (float)$duration;
|
||||||
|
|
||||||
if(x($a->config,'system') && x($a->config['system'],'db_log')) {
|
if(x($a->config,'system') && x($a->config['system'],'db_log')) {
|
||||||
$stamp2 = microtime(true);
|
|
||||||
$duration = round($stamp2-$stamp1, 3);
|
|
||||||
if (($duration > $a->config["system"]["db_loglimit"])) {
|
if (($duration > $a->config["system"]["db_loglimit"])) {
|
||||||
|
$duration = round($duration, 3);
|
||||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
@file_put_contents($a->config["system"]["db_log"], $duration."\t".
|
@file_put_contents($a->config["system"]["db_log"], $duration."\t".
|
||||||
basename($backtrace[1]["file"])."\t".
|
basename($backtrace[1]["file"])."\t".
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
if(! function_exists('fetch_url')) {
|
if(! function_exists('fetch_url')) {
|
||||||
function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_content=Null) {
|
function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_content=Null) {
|
||||||
|
|
||||||
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
$ch = @curl_init($url);
|
$ch = @curl_init($url);
|
||||||
|
@ -101,6 +103,11 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
|
||||||
$body = substr($s,strlen($header));
|
$body = substr($s,strlen($header));
|
||||||
$a->set_curl_headers($header);
|
$a->set_curl_headers($header);
|
||||||
@curl_close($ch);
|
@curl_close($ch);
|
||||||
|
|
||||||
|
$stamp2 = microtime(true);
|
||||||
|
$duration = (float)($stamp2-$stamp1);
|
||||||
|
$a->performance["network"] += (float)$duration;
|
||||||
|
|
||||||
return($body);
|
return($body);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -108,6 +115,9 @@ function fetch_url($url,$binary = false, &$redirects = 0, $timeout = 0, $accept_
|
||||||
|
|
||||||
if(! function_exists('post_url')) {
|
if(! function_exists('post_url')) {
|
||||||
function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) {
|
function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0) {
|
||||||
|
|
||||||
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
$ch = curl_init($url);
|
$ch = curl_init($url);
|
||||||
if(($redirects > 8) || (! $ch))
|
if(($redirects > 8) || (! $ch))
|
||||||
|
@ -190,6 +200,11 @@ function post_url($url,$params, $headers = null, &$redirects = 0, $timeout = 0)
|
||||||
$a->set_curl_headers($header);
|
$a->set_curl_headers($header);
|
||||||
|
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
|
$stamp2 = microtime(true);
|
||||||
|
$duration = (float)($stamp2-$stamp1);
|
||||||
|
$a->performance["network"] += (float)$duration;
|
||||||
|
|
||||||
return($body);
|
return($body);
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,8 @@ if(! function_exists('replace_macros')) {
|
||||||
function replace_macros($s,$r) {
|
function replace_macros($s,$r) {
|
||||||
global $t;
|
global $t;
|
||||||
|
|
||||||
// $ts = microtime();
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
if($a->theme['template_engine'] === 'smarty3') {
|
if($a->theme['template_engine'] === 'smarty3') {
|
||||||
|
@ -37,9 +38,11 @@ function replace_macros($s,$r) {
|
||||||
|
|
||||||
$output = template_unescape($r);
|
$output = template_unescape($r);
|
||||||
}
|
}
|
||||||
// $tt = microtime() - $ts;
|
$a = get_app();
|
||||||
// $a = get_app();
|
$stamp2 = microtime(true);
|
||||||
// $a->page['debug'] .= "$tt <br>\n";
|
$duration = (float)($stamp2-$stamp1);
|
||||||
|
$a->performance["rendering"] += (float)$duration;
|
||||||
|
|
||||||
return $output;
|
return $output;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
@ -458,7 +461,8 @@ function get_intltext_template($s) {
|
||||||
|
|
||||||
if(! function_exists('get_markup_template')) {
|
if(! function_exists('get_markup_template')) {
|
||||||
function get_markup_template($s, $root = '') {
|
function get_markup_template($s, $root = '') {
|
||||||
// $ts = microtime();
|
$stamp1 = microtime(true);
|
||||||
|
|
||||||
$a = get_app();
|
$a = get_app();
|
||||||
|
|
||||||
if($a->theme['template_engine'] === 'smarty3') {
|
if($a->theme['template_engine'] === 'smarty3') {
|
||||||
|
@ -467,16 +471,19 @@ function get_markup_template($s, $root = '') {
|
||||||
$template = new FriendicaSmarty();
|
$template = new FriendicaSmarty();
|
||||||
$template->filename = $template_file;
|
$template->filename = $template_file;
|
||||||
|
|
||||||
// $tt = microtime() - $ts;
|
$stamp2 = microtime(true);
|
||||||
// $a->page['debug'] .= "$tt <br>\n";
|
$duration = (float)($stamp2-$stamp1);
|
||||||
|
$a->performance["rendering"] += (float)$duration;
|
||||||
|
|
||||||
return $template;
|
return $template;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$template_file = get_template_file($a, $s, $root);
|
$template_file = get_template_file($a, $s, $root);
|
||||||
// $file_contents = file_get_contents($template_file);
|
|
||||||
// $tt = microtime() - $ts;
|
$stamp2 = microtime(true);
|
||||||
// $a->page['debug'] .= "$tt <br>\n";
|
$duration = (float)($stamp2-$stamp1);
|
||||||
// return $file_contents;
|
$a->performance["rendering"] += (float)$duration;
|
||||||
|
|
||||||
return file_get_contents($template_file);
|
return file_get_contents($template_file);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Reference in a new issue