6 * Description: Shows the time that was needed to render the current page
8 * Author: Michael Vvogel <http://pirati.ca/profile/heluecht>
12 use Friendica\Core\Config;
14 function rendertime_install() {
15 register_hook('page_end', 'addon/rendertime/rendertime.php', 'rendertime_page_end');
19 function rendertime_uninstall() {
20 unregister_hook('init_1', 'addon/rendertime/rendertime.php', 'rendertime_init_1');
21 unregister_hook('page_end', 'addon/rendertime/rendertime.php', 'rendertime_page_end');
24 function rendertime_init_1(&$a) {
27 function rendertime_page_end(&$a, &$o) {
29 $duration = microtime(true)-$a->performance["start"];
31 $ignored_modules = array("fbrowser");
32 $ignored = in_array($a->module, $ignored_modules);
34 if (is_site_admin() && ($_GET["mode"] != "minimal") && !$a->is_mobile && !$a->is_tablet && !$ignored) {
35 $o = $o.'<div class="renderinfo">'.sprintf(t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s"),
36 round($a->performance["database"] - $a->performance["database_write"], 3),
37 round($a->performance["database_write"], 3),
38 round($a->performance["network"], 2),
39 round($a->performance["rendering"], 2),
40 round($a->performance["parser"], 2),
41 round($a->performance["file"], 2),
42 round($duration - $a->performance["database"]
43 - $a->performance["network"] - $a->performance["rendering"]
44 - $a->performance["parser"] - $a->performance["file"], 2),
46 //round($a->performance["markstart"], 3)
47 //round($a->performance["plugin"], 3)
50 if (Config::get("rendertime", "callstack")) {
52 $o .= "\nDatabase Read:\n";
53 foreach ($a->callstack["database"] AS $func => $time) {
54 $time = round($time, 3);
56 $o .= $func.": ".$time."\n";
58 $o .= "\nDatabase Write:\n";
59 foreach ($a->callstack["database_write"] AS $func => $time) {
60 $time = round($time, 3);
62 $o .= $func.": ".$time."\n";
66 foreach ($a->callstack["network"] AS $func => $time) {
67 $time = round($time, 3);
69 $o .= $func.": ".$time."\n";