thigobr commited on
Commit
2b87e85
·
verified ·
1 Parent(s): 6748f9d

use simple time

Browse files
Files changed (1) hide show
  1. app.py +18 -9
app.py CHANGED
@@ -5,6 +5,10 @@ from PIL import Image
5
  import cProfile
6
  import pstats
7
  from io import StringIO
 
 
 
 
8
 
9
  # Streamlit app
10
  def main():
@@ -30,24 +34,29 @@ def main():
30
 
31
  uploaded_file = st.sidebar.file_uploader("Choose a PDF file", type="pdf")
32
  if uploaded_file is not None:
33
- profiler = cProfile.Profile()
34
- profiler.enable()
35
  st.sidebar.success("File uploaded successfully.")
 
36
  vector_store = PDF_4_QA(uploaded_file)
 
 
 
37
  QA_Bot(vector_store)
38
- profiler.disable()
39
- #stats.print_stats()
40
- s = StringIO()
41
- ps = pstats.Stats(profiler, stream=s).sort_stats('cumulative')
 
42
 
43
  # Print the profiling results to the StringIO object
44
- ps.print_stats()
45
 
46
  # Get the profiling results as a string
47
- profiling_results = s.getvalue()
48
 
49
  # Print the profiling results
50
- st.session_state.messages.append({"role": "assistant", "content": profiling_results})
51
 
52
 
53
  if __name__ == '__main__':
 
5
  import cProfile
6
  import pstats
7
  from io import StringIO
8
+ import time
9
+
10
+ def print_time(start, end):
11
+ st.session_state.messages.append({"role": "assistant", "content": f"Execution time: {end - start} seconds}")
12
 
13
  # Streamlit app
14
  def main():
 
34
 
35
  uploaded_file = st.sidebar.file_uploader("Choose a PDF file", type="pdf")
36
  if uploaded_file is not None:
37
+ # profiler = cProfile.Profile()
38
+ # profiler.enable()
39
  st.sidebar.success("File uploaded successfully.")
40
+ start_time = time.time()
41
  vector_store = PDF_4_QA(uploaded_file)
42
+ end_time = time.time()
43
+ print_time(start_time, end_time)
44
+ start_time = time.time()
45
  QA_Bot(vector_store)
46
+ end_time = time.time()
47
+ print_time(start_time, end_time)
48
+ # profiler.disable()
49
+ # s = StringIO()
50
+ # ps = pstats.Stats(profiler, stream=s).sort_stats('cumulative')
51
 
52
  # Print the profiling results to the StringIO object
53
+ # ps.print_stats()
54
 
55
  # Get the profiling results as a string
56
+ # profiling_results = s.getvalue()
57
 
58
  # Print the profiling results
59
+ # st.session_state.messages.append({"role": "assistant", "content": profiling_results})
60
 
61
 
62
  if __name__ == '__main__':