diff --git a/benchmark.py b/benchmark.py deleted file mode 100644 index 61d5d8ab..00000000 --- a/benchmark.py +++ /dev/null @@ -1,33 +0,0 @@ -import time -import pandas as pd -import numpy as np - -# We want to benchmark the difference between iterating with a list comprehension -# vs vectorized str.lower() method for pd.DataFrame column manipulation. - -# Let's create a DataFrame with many columns to see the difference clearly. -# For a typical stock dataframe, the number of columns is small (e.g. 6-7). -# Let's benchmark for both a small DataFrame and a very large DataFrame. - -def benchmark(num_cols, iterations): - cols = [f"Col_{i}" for i in range(num_cols)] - df = pd.DataFrame(columns=cols) - - start = time.time() - for _ in range(iterations): - _ = [str(c).lower() for c in df.columns] - t1 = time.time() - start - - start = time.time() - for _ in range(iterations): - _ = df.columns.astype(str).str.lower() - t2 = time.time() - start - - print(f"Num cols: {num_cols}, Iterations: {iterations}") - print(f"List comprehension: {t1:.6f} s") - print(f"Pandas str.lower(): {t2:.6f} s") - print("-" * 30) - -benchmark(10, 10000) -benchmark(100, 10000) -benchmark(1000, 10000) diff --git a/cli/main.py b/cli/main.py index f490152a..17a53c04 100644 --- a/cli/main.py +++ b/cli/main.py @@ -140,10 +140,13 @@ class MessageBuffer: This prevents interim updates (like debate rounds) from counting as completed. """ + # Optimized: Iterate over active report sections directly instead of all possible sections, + # checking content first to short-circuit the finalizing agent status lookup. count = 0 - for section, (_, finalizing_agent) in self.REPORT_SECTIONS.items(): - if self.report_sections.get(section) is not None: - if self.agent_status.get(finalizing_agent) == "completed": + for section, content in self.report_sections.items(): + if content is not None: + section_info = self.REPORT_SECTIONS.get(section) + if section_info and self.agent_status.get(section_info[1]) == "completed": count += 1 return count