Skip to content

A live bird collage card for your Home Assistant dashboard.

plotly_streamlit.py: add easy profiling

frederik66a3af6f9f50
diff --git a/scripts/plotly_streamlit.py b/scripts/plotly_streamlit.py
index 8232564e..34ba5ee6 100755
--- a/scripts/plotly_streamlit.py
+++ b/scripts/plotly_streamlit.py
@@ -14,6 +14,18 @@ from sklearn.preprocessing import normalize
from suntime import Sun
from datetime import datetime
+profile = False
+if profile:
+ try:
+ from pyinstrument import Profiler
+ except ImportError as e:
+ print(e)
+ profile = False
+ else:
+ profiler = Profiler()
+ profiler.start()
+
+
pio.templates.default = "plotly_white"
userDir = os.path.expanduser('~')
@@ -539,3 +551,7 @@ else:
# audio_file = open('/home/*/BirdSongs/Extracted/By_Date/2022-03-22/Yellow-streaked_Greenbul/Yellow-streaked_Greenbul-77-2022-03-22-birdnet-15:04:28.mp3', 'rb')
# audio_bytes = audio_file.read()
# cols4.audio(audio_bytes, format='audio/mp3')
+if profile:
+ profiler.stop()
+ profiler.print()
+ print('**profiler done**', flush=True)