File tree 1 file changed +6
-4
lines changed
devops/scripts/benchmarks
1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -40,13 +40,15 @@ def load(self, n: int):
40
40
benchmark_files = list (results_dir .glob ("*.json" ))
41
41
42
42
# Extract timestamp and sort files by it
43
- def extract_timestamp (file_path : Path ) -> str :
43
+ def extract_timestamp (file_path : Path ) -> datetime :
44
44
try :
45
45
# Assumes results are stored as <name>_YYYYMMDD_HHMMSS.json
46
46
ts = file_path .stem [- len ("YYYYMMDD_HHMMSS" ) :]
47
- return ts if Validate .timestamp (ts ) else ""
48
- except IndexError :
49
- return ""
47
+ if Validate .timestamp (ts ):
48
+ return datetime .strptime (ts , "%Y%m%d_%H%M%S" )
49
+ return datetime .fromtimestamp (0 ) # Default to epoch if invalid
50
+ except (IndexError , ValueError ):
51
+ return datetime .fromtimestamp (0 ) # Default to epoch if exception
50
52
51
53
benchmark_files .sort (key = extract_timestamp , reverse = True )
52
54
You can’t perform that action at this time.
0 commit comments