]> git.mxchange.org Git - friendica-addons.git/blob - rendertime/rendertime.php
Merge branch 'master' of github.com:annando/friendica-addons
[friendica-addons.git] / rendertime / rendertime.php
1 <?php
2
3
4 /**
5  * Name: rendertime
6  * Description: Shows the time that was needed to render the current page
7  * Version: 0.1
8  * Author: Michael Vvogel <http://pirati.ca/profile/heluecht>
9  *
10  */
11
12 function rendertime_install() {
13         register_hook('init_1', 'addon/rendertime/rendertime.php', 'rendertime_init_1');
14         register_hook('page_end', 'addon/rendertime/rendertime.php', 'rendertime_page_end');
15 }
16
17
18 function rendertime_uninstall() {
19         unregister_hook('init_1', 'addon/rendertime/rendertime.php', 'rendertime_init_1');
20         unregister_hook('page_end', 'addon/rendertime/rendertime.php', 'rendertime_page_end');
21 }
22
23 function rendertime_init_1(&$a) {
24         global $rendertime_start;
25
26         $rendertime_start = microtime(true);
27 }
28
29 function rendertime_page_end(&$a, &$o) {
30         global $rendertime_start;
31
32         $duration = round(microtime(true)-$rendertime_start, 3);
33
34         $o = $o.'<div class="renderinfo">'.sprintf(t("This page took %s seconds to render"), $duration)."</div>";
35 }