File size: 603 Bytes
739e275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import cProfile

from fasthtml.common import *
from starlette.testclient import TestClient

# Import your FastHTML app and weeks
from app import app, weeks


def profile_app():
    """Profile the FastHTML app!"""
    client = TestClient(app)

    # Test home page
    client.get("/")

    # Test 10 weeks (or fewer if less than 5 weeks available)
    for week in weeks[: min(10, len(weeks))]:
        client.get(f"/week/{week}")


if __name__ == "__main__":
    # Run the profiling
    cProfile.run("profile_app()", "profile_output.prof")

    # python profile_app.py
    # snakeviz profile_output.prof