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 %}
<li>{{ name }} took {{ "%.1f" | format(seconds) }} seconds</li>
{% endfor %}
<li>Render time: {{ "%.1f" | format(render_time) }} seconds</li>
</ul>
</div>

View file

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