mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-28 16:25:00 +00:00
perf: optimize benchmark dir search by filtering on timestamp first
This commit is contained in:
parent
a89ce06377
commit
320b059bc7
1 changed files with 22 additions and 1 deletions
|
@ -47,8 +47,29 @@ def find_latest_benchmark_dir():
|
|||
print("Error: No benchmark directories found under tmp.benchmarks.")
|
||||
sys.exit(1)
|
||||
|
||||
# Get current time and 24 hours ago
|
||||
now = datetime.datetime.now()
|
||||
day_ago = now - datetime.timedelta(days=1)
|
||||
|
||||
# Filter directories by name pattern YYYY-MM-DD-HH-MM-SS--
|
||||
recent_dirs = []
|
||||
for d in benchmark_dirs:
|
||||
try:
|
||||
# Extract datetime from directory name
|
||||
date_str = d.name[:19] # Takes YYYY-MM-DD-HH-MM-SS
|
||||
dir_date = datetime.datetime.strptime(date_str, "%Y-%m-%d-%H-%M-%S")
|
||||
if dir_date >= day_ago:
|
||||
recent_dirs.append(d)
|
||||
except ValueError:
|
||||
# Skip directories that don't match the expected format
|
||||
continue
|
||||
|
||||
if not recent_dirs:
|
||||
print("Error: No benchmark directories found from the last 24 hours.")
|
||||
sys.exit(1)
|
||||
|
||||
latest_dir = max(
|
||||
benchmark_dirs,
|
||||
recent_dirs,
|
||||
key=lambda d: next((f.stat().st_mtime for f in d.glob("*/.*.md") if f.is_file()), 0),
|
||||
)
|
||||
print(f"Using the most recently updated benchmark directory: {latest_dir.name}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue