X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=rendertime%2Frendertime.php;h=534568cacb7363d9bd548011e83eef5ac574745b;hb=308ba3ce8cdb2c30e538dbf219ee3ed6f1528ef7;hp=87a32901924263bc0aec33f027ff2a73ff47e4ea;hpb=0c03f13a96fc6cdb2bc6e3bf926297ad7a70b17e;p=friendica-addons.git diff --git a/rendertime/rendertime.php b/rendertime/rendertime.php old mode 100755 new mode 100644 index 87a32901..534568ca --- a/rendertime/rendertime.php +++ b/rendertime/rendertime.php @@ -9,8 +9,9 @@ * */ +use Friendica\Core\Config; + function rendertime_install() { - register_hook('init_1', 'addon/rendertime/rendertime.php', 'rendertime_init_1'); register_hook('page_end', 'addon/rendertime/rendertime.php', 'rendertime_page_end'); } @@ -21,15 +22,54 @@ function rendertime_uninstall() { } function rendertime_init_1(&$a) { - global $rendertime_start; - - $rendertime_start = microtime(true); } function rendertime_page_end(&$a, &$o) { - global $rendertime_start; - $duration = round(microtime(true)-$rendertime_start, 3); + $duration = microtime(true)-$a->performance["start"]; + + $ignored_modules = array("fbrowser"); + $ignored = in_array($a->module, $ignored_modules); + + if (is_site_admin() && ($_GET["mode"] != "minimal") && !$a->is_mobile && !$a->is_tablet && !$ignored) { + $o = $o.'
'.sprintf(t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s"), + round($a->performance["database"] - $a->performance["database_write"], 3), + round($a->performance["database_write"], 3), + round($a->performance["network"], 2), + round($a->performance["rendering"], 2), + round($a->performance["parser"], 2), + round($a->performance["file"], 2), + round($duration - $a->performance["database"] + - $a->performance["network"] - $a->performance["rendering"] + - $a->performance["parser"] - $a->performance["file"], 2), + round($duration, 2) + //round($a->performance["markstart"], 3) + //round($a->performance["plugin"], 3) + )."
"; + + if (Config::get("rendertime", "callstack")) { + $o .= "
";
+			$o .= "\nDatabase Read:\n";
+			foreach ($a->callstack["database"] AS $func => $time) {
+				$time = round($time, 3);
+				if ($time > 0)
+					$o .= $func.": ".$time."\n";
+			}
+			$o .= "\nDatabase Write:\n";
+			foreach ($a->callstack["database_write"] AS $func => $time) {
+				$time = round($time, 3);
+				if ($time > 0)
+					$o .= $func.": ".$time."\n";
+			}
+
+			$o .= "\nNetwork:\n";
+			foreach ($a->callstack["network"] AS $func => $time) {
+				$time = round($time, 3);
+				if ($time > 0)
+					$o .= $func.": ".$time."\n";
+			}
 
-	$o = $o.'
'.sprintf(t("This page took %s seconds to render"), $duration)."
"; + $o .= "
"; + } + } }