]> git.mxchange.org Git - friendica-addons.git/blob - rendertime/rendertime.php
Merge pull request #100 from tonybaldwin/master
[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('page_end', 'addon/rendertime/rendertime.php', 'rendertime_page_end');
14 }
15
16
17 function rendertime_uninstall() {
18         unregister_hook('init_1', 'addon/rendertime/rendertime.php', 'rendertime_init_1');
19         unregister_hook('page_end', 'addon/rendertime/rendertime.php', 'rendertime_page_end');
20 }
21
22 function rendertime_init_1(&$a) {
23 }
24
25 function rendertime_page_end(&$a, &$o) {
26
27         $duration = microtime(true)-$a->performance["start"];
28
29         $o = $o.'<div class="renderinfo">'.sprintf(t("Performance: Database: %s, Network: %s, Rendering: %s, Parser: %s, I/O: %s, Other: %s, Total: %s"),
30                                                 round($a->performance["database"], 3),
31                                                 round($a->performance["network"], 3),
32                                                 round($a->performance["rendering"], 3),
33                                                 round($a->performance["parser"], 3),
34                                                 round($a->performance["file"], 3),
35                                                 round($duration - $a->performance["database"] - $a->performance["network"]
36                                                          - $a->performance["rendering"] - $a->performance["parser"]
37                                                          - $a->performance["file"], 3),
38                                                 round($duration, 3)
39                                                 //round($a->performance["markstart"], 3)
40                                                 //round($a->performance["plugin"], 3)
41                                                 )."</div>";
42
43 }