rbiswasfc commited on
Commit
75d46f7
1 Parent(s): 7490f8c
Files changed (1) hide show
  1. profile_app.py +36 -36
profile_app.py CHANGED
@@ -1,52 +1,52 @@
1
- import cProfile
2
- import multiprocessing
3
- import time
4
 
5
- import requests
6
- from fasthtml.common import *
7
 
8
- from app import serve, weeks
9
 
10
- PORT = 7860 # Update this to match the port your app is using
11
 
12
 
13
- def run_server():
14
- serve() # This should start your FastHTML app
15
 
16
 
17
- def make_requests():
18
- base_url = f"http://127.0.0.1:{PORT}"
19
 
20
- # Test home page
21
- try:
22
- requests.get(f"{base_url}/")
23
- except requests.exceptions.RequestException as e:
24
- print(f"Error accessing home page: {e}")
25
 
26
- # Test 5 weeks (or fewer if less than 5 weeks available)
27
- for week in weeks[: min(5, len(weeks))]:
28
- try:
29
- requests.get(f"{base_url}/week/{week}")
30
- except requests.exceptions.RequestException as e:
31
- print(f"Error accessing week {week}: {e}")
32
 
33
- # Add more requests here to cover other parts of your application
34
 
35
 
36
- def profile_app():
37
- server_process = multiprocessing.Process(target=run_server)
38
- server_process.start()
39
 
40
- # Wait for the server to start
41
- time.sleep(5) # Increased wait time
42
 
43
- try:
44
- make_requests()
45
- finally:
46
- server_process.terminate()
47
- server_process.join()
48
 
49
 
50
- if __name__ == "__main__":
51
- cProfile.run("profile_app()", "profile_output.prof")
52
- print("Profiling complete. Run 'snakeviz profile_output.prof' to view results.")
 
1
+ # import cProfile
2
+ # import multiprocessing
3
+ # import time
4
 
5
+ # import requests
6
+ # from fasthtml.common import *
7
 
8
+ # from app import serve, weeks
9
 
10
+ # PORT = 7860 # Update this to match the port your app is using
11
 
12
 
13
+ # def run_server():
14
+ # serve() # This should start your FastHTML app
15
 
16
 
17
+ # def make_requests():
18
+ # base_url = f"http://127.0.0.1:{PORT}"
19
 
20
+ # # Test home page
21
+ # try:
22
+ # requests.get(f"{base_url}/")
23
+ # except requests.exceptions.RequestException as e:
24
+ # print(f"Error accessing home page: {e}")
25
 
26
+ # n_weeks = 10
27
+ # for week in weeks[: min(n_weeks, len(weeks))]:
28
+ # try:
29
+ # requests.get(f"{base_url}/week/{week}")
30
+ # except requests.exceptions.RequestException as e:
31
+ # print(f"Error accessing week {week}: {e}")
32
 
33
+ # # Add more requests here to cover other parts of your application
34
 
35
 
36
+ # def profile_app():
37
+ # server_process = multiprocessing.Process(target=run_server)
38
+ # server_process.start()
39
 
40
+ # # Wait for the server to start
41
+ # time.sleep(60)
42
 
43
+ # try:
44
+ # make_requests()
45
+ # finally:
46
+ # server_process.terminate()
47
+ # server_process.join()
48
 
49
 
50
+ # if __name__ == "__main__":
51
+ # cProfile.run("profile_app()", "profile_output.prof")
52
+ # print("Profiling complete. Run 'snakeviz profile_output.prof' to view results.")