Show page render time on events list

This commit is contained in:
Edward Betts 2024-08-04 12:01:54 +08:00
parent 11bc0419b3
commit 15c5053e44
2 changed files with 4 additions and 0 deletions

View file

@ -150,6 +150,7 @@
{% for name, seconds in timings %} {% for name, seconds in timings %}
<li>{{ name }} took {{ "%.1f" | format(seconds) }} seconds</li> <li>{{ name }} took {{ "%.1f" | format(seconds) }} seconds</li>
{% endfor %} {% endfor %}
<li>Render time: {{ "%.1f" | format(render_time) }} seconds</li>
</ul> </ul>
</div> </div>

View file

@ -7,6 +7,7 @@ import inspect
import operator import operator
import os.path import os.path
import sys import sys
import time
import traceback import traceback
from collections import defaultdict from collections import defaultdict
from datetime import date, datetime, timedelta from datetime import date, datetime, timedelta
@ -70,6 +71,7 @@ def exception_handler(e: werkzeug.exceptions.InternalServerError) -> tuple[str,
@app.route("/") @app.route("/")
async def index() -> str: async def index() -> str:
"""Index page.""" """Index page."""
t0 = time.time()
now = datetime.now() now = datetime.now()
data = await agenda.data.get_data(now, app.config) data = await agenda.data.get_data(now, app.config)
@ -88,6 +90,7 @@ async def index() -> str:
fullcalendar_events=calendar.build_events(events), fullcalendar_events=calendar.build_events(events),
start_event_list=date.today() - timedelta(days=1), start_event_list=date.today() - timedelta(days=1),
end_event_list=date.today() + timedelta(days=365 * 2), end_event_list=date.today() + timedelta(days=365 * 2),
render_time=(time.time() - t0),
**data, **data,
) )