Bug 40813 - Add ability to embed page start and end timing
Summary: Add ability to embed page start and end timing
Status: Needs Signoff
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement
Assignee: Kyle M Hall (khall)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-15 19:19 UTC by Kyle M Hall (khall)
Modified: 2026-01-29 16:52 UTC (History)
2 users (show)

See Also:
GIT URL:
Initiative type: ---
Sponsorship status: ---
Comma delimited list of Sponsors:
Crowdfunding goal: 0
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40813: Add ability to embed page start and end timing (2.52 KB, patch)
2025-09-15 19:21 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 40813: Add ability to embed page start and end timing (6.28 KB, patch)
2025-09-16 16:51 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review
Mockup of the times in the footer (143.56 KB, image/png)
2026-01-27 13:17 UTC, Owen Leonard
Details
Bug 40813: Move timings to existing footer (15.49 KB, patch)
2026-01-28 12:55 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 40813: (follow-up) Add some CSS, udpate navbar structure (6.36 KB, patch)
2026-01-28 18:10 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 40813: Add ability to embed page start and end timing (2.58 KB, patch)
2026-01-29 16:51 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 40813: Move timings to existing footer (15.55 KB, patch)
2026-01-29 16:52 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 40813: (follow-up) Add some CSS, udpate navbar structure (6.43 KB, patch)
2026-01-29 16:52 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review
Bug 40813: (follow-up) Add milliseconds (3.48 KB, patch)
2026-01-29 16:52 UTC, Kyle M Hall (khall)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall (khall) 2025-09-15 19:19:55 UTC
It would be useful to know what time a page load was initiated and rendering completed for debugging purposes. The most reasonable solution I've found is to get a time from the start of get_template_and_user and the end of intranet-bottom.inc.
Comment 1 Kyle M Hall (khall) 2025-09-15 19:21:59 UTC
Created attachment 186445 [details] [review]
Bug 40813: Add ability to embed page start and end timing

It would be useful to know what time a page load was initiated and
rendering completed for debugging purposes. The most reasonable solution
I've found is to get a time from the start of get_template_and_user and
the end of intranet-bottom.inc. This adds timing to nearly all Koha
pages with just a few lines of code.

Test Plan:
1) Apply this patch
2) Restart all the things!
3) Load mainpage.pl
4) Note the "start" and "end" values at the bottom of the page
Comment 2 Kyle M Hall (khall) 2025-09-15 19:24:25 UTC
Open questions:
1) Do we need to hide this data by default using CSS or a syspref? If so, which?

2) Can anyone style this information better?
Comment 3 Lucas Gass (lukeg) 2025-09-16 14:40:45 UTC
(In reply to Kyle M Hall (khall) from comment #2)
> Open questions:
> 1) Do we need to hide this data by default using CSS or a syspref? If so,
> which?

In my opinion it should be by system preference. Perhaps "DumpTemplateLoadTimes"?
Comment 4 Lucas Gass (lukeg) 2025-09-16 16:51:41 UTC
Created attachment 186490 [details] [review]
Bug 40813: Add ability to embed page start and end timing

It would be useful to know what time a page load was initiated and
rendering completed for debugging purposes. The most reasonable solution
I've found is to get a time from the start of get_template_and_user and
the end of intranet-bottom.inc. This adds timing to nearly all Koha
pages with just a few lines of code.

Test Plan:
1) Apply this patch
2) Restart all the things!
3) Load mainpage.pl
4) Note the "start" and "end" values at the bottom of the page
Comment 5 Katrin Fischer 2026-01-27 07:06:14 UTC
1) QA checks - failing (blocker)

I am not sure about the span error. I have tried to spot it, but failed. But will be interesting to check maybe. 

Processing files
[RUNNING] C4/Auth.pm
[RUNNING] koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc
[                                                  ] 0/2 tests completed
[error] E3jaz8Qpz5.tt: SyntaxError: Unexpected closing tag "span". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (4:9)
[error]   2 |     #~136~#
[error]   3 |     #~137~#
[error] > 4 |         </span>
[error]     |         ^^^^^^^
[error]   5 |   </div>
[error]   6 | </footer>
[FAIL] koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc
[PASS] C4/Auth.pm

Result:
[PASS] C4/Auth.pm
[FAIL] koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc
   FAIL	  filters
		missing_filter at line 301 (        <span class="navbar-text start_time" data-start="[% start_time %]">)
		missing_filter at line 303 (            [% start_time.hms(':') %])
		missing_filter at line 306 (        <span class="navbar-text end_time" data-end="[% end_time %]">)
		missing_filter at line 308 (            [% end_time.hms(':') %])
   FAIL	  tidiness
		File is not tidy, please run `perl misc/devel/tidy.pl koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc`

Processing additional checks PASS!

2) Code review

Nothing spotted.

3) Testing

a) System preference / Debug setting (blocker)

It works as described, but I agree with Lucas' comment about the preference. This should be optional and have a switch to turn on/off

b) Styling (no blocker)

Right now it doesn't stay at the bottom of the page but moves up on pages with not a lot of content. For testing it might be nicer to "pin" it to the bottom, so you can compare a little easier between pages, etc. because it's always in the same spot.
Comment 6 Owen Leonard 2026-01-27 13:17:49 UTC
Created attachment 192095 [details]
Mockup of the times in the footer

Maybe it could be shown in a footer like the language selectors? We'd have to re-do the logic on when to show it.
Comment 7 Katrin Fischer 2026-01-27 18:52:36 UTC
(In reply to Owen Leonard from comment #6)
> Created attachment 192095 [details]
> Mockup of the times in the footer
> 
> Maybe it could be shown in a footer like the language selectors? We'd have
> to re-do the logic on when to show it.

That looks really great to me. How would it look like if there are no other languages active?
Comment 8 Kyle M Hall (khall) 2026-01-28 12:55:36 UTC
Created attachment 192117 [details] [review]
Bug 40813: Move timings to existing footer
Comment 9 Kyle M Hall (khall) 2026-01-28 12:56:25 UTC
Own, I think I've got the logic fixed, but I have failed to style it correctly. Can you have a look? Thanks!
Comment 10 Owen Leonard 2026-01-28 18:10:49 UTC
Created attachment 192128 [details] [review]
Bug 40813: (follow-up) Add some CSS, udpate navbar structure

This follow-up changes the structure of the footer navbar markup so that
it avoids IDs related to "language" since its purpose is now more
general.

The start and end time markup is adjusted for being inside a navbar and
to align it to the right away from the language menu (if present).

Also changed: Added missing html filters and fixed a minor tidy
complaint in Auth.pm.
Comment 11 Owen Leonard 2026-01-28 18:12:15 UTC
It occurs to me that this would be even more useful if it output milliseconds too.
Comment 12 Kyle M Hall (khall) 2026-01-29 16:51:53 UTC
Created attachment 192167 [details] [review]
Bug 40813: Add ability to embed page start and end timing

It would be useful to know what time a page load was initiated and
rendering completed for debugging purposes. The most reasonable solution
I've found is to get a time from the start of get_template_and_user and
the end of intranet-bottom.inc. This adds timing to nearly all Koha
pages with just a few lines of code.

Test Plan:
1) Apply this patch
2) Restart all the things!
3) Load mainpage.pl
4) Note the "start" and "end" values at the bottom of the page

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 13 Kyle M Hall (khall) 2026-01-29 16:52:07 UTC
Created attachment 192168 [details] [review]
Bug 40813: Move timings to existing footer

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 14 Kyle M Hall (khall) 2026-01-29 16:52:09 UTC
Created attachment 192169 [details] [review]
Bug 40813: (follow-up) Add some CSS, udpate navbar structure

This follow-up changes the structure of the footer navbar markup so that
it avoids IDs related to "language" since its purpose is now more
general.

The start and end time markup is adjusted for being inside a navbar and
to align it to the right away from the language menu (if present).

Also changed: Added missing html filters and fixed a minor tidy
complaint in Auth.pm.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 15 Kyle M Hall (khall) 2026-01-29 16:52:12 UTC
Created attachment 192170 [details] [review]
Bug 40813: (follow-up) Add milliseconds

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>