4 * Description: Shows the time that was needed to render the current page
6 * Author: Michael Vogel <http://pirati.ca/profile/heluecht>
10 use Friendica\Core\Hook;
11 use Friendica\Core\L10n;
14 function rendertime_install() {
15 Hook::register('page_end', 'addon/rendertime/rendertime.php', 'rendertime_page_end');
19 function rendertime_uninstall() {
20 Hook::unregister('init_1', 'addon/rendertime/rendertime.php', 'rendertime_init_1');
21 Hook::unregister('page_end', 'addon/rendertime/rendertime.php', 'rendertime_page_end');
24 function rendertime_init_1(&$a) {
28 * @param Friendica\App $a
31 function rendertime_page_end(Friendica\App $a, &$o)
34 $profiler = DI::profiler();
36 $duration = microtime(true) - $profiler->get('start');
38 $ignored_modules = ["fbrowser"];
39 $ignored = in_array(DI::module()->getName(), $ignored_modules);
41 if (is_site_admin() && (($_GET['mode'] ?? '') != 'minimal') && !DI::mode()->isMobile() && !DI::mode()->isMobile() && !$ignored) {
43 $o = $o . '<div class="renderinfo">' . L10n::t("Database: %s/%s, Network: %s, Rendering: %s, Session: %s, I/O: %s, Other: %s, Total: %s",
44 round($profiler->get('database') - $profiler->get('database_write'), 3),
45 round($profiler->get('database_write'), 3),
46 round($profiler->get('network'), 2),
47 round($profiler->get('rendering'), 2),
48 round($profiler->get('parser'), 2),
49 round($profiler->get('file'), 2),
50 round($duration - $profiler->get('database')
51 - $profiler->get('network') - $profiler->get('rendering')
52 - $profiler->get('parser') - $profiler->get('file'), 2),
54 //round($profiler->get('markstart'), 3)
55 //round($profiler->get('plugin'), 3)
58 if ($profiler->isRendertime()) {
60 $o .= $profiler->getRendertimeString();