Spaces:
Sleeping
Sleeping
app
Browse files- 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 |
-
|
| 15 |
|
| 16 |
|
| 17 |
-
def make_requests():
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
-
|
| 34 |
|
| 35 |
|
| 36 |
-
def profile_app():
|
| 37 |
-
|
| 38 |
-
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
|
| 49 |
|
| 50 |
-
if __name__ == "__main__":
|
| 51 |
-
|
| 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 |
+
# 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.")
|