Skip to content

Commit 0dcf2f0

Browse files
committed
chore: add version and timestamp to benchmark SVG filenames
1 parent fb64cee commit 0dcf2f0

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ cmd = "pytest"
9393
help = "Run tests"
9494

9595
[tool.poe.tasks.test-perf]
96-
cmd = "pytest -m perf -v --benchmark-autosave --benchmark-histogram"
96+
sequence = [
97+
{ cmd = "pytest -m perf -v --benchmark-autosave --benchmark-histogram" },
98+
{ script = "scripts.rename_benchmark:main" },
99+
]
97100
help = "Run performance tests"
98101

99102
[tool.poe.tasks.update-deps]

scripts/__init__.py

Whitespace-only changes.

scripts/rename_benchmark.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
"""Rename benchmark SVG files with version and timestamp suffix."""
2+
3+
import glob
4+
import re
5+
import shutil
6+
from pathlib import Path
7+
8+
9+
def main():
10+
"""Rename benchmark_*.svg to benchmark_v{version}_{timestamp}.svg."""
11+
# Read version from pyproject.toml
12+
pyproject = Path("pyproject.toml")
13+
if not pyproject.exists():
14+
print("pyproject.toml not found")
15+
return
16+
17+
version = None
18+
for line in pyproject.read_text().splitlines():
19+
if line.startswith("version = "):
20+
version = line.split('"')[1]
21+
break
22+
23+
if not version:
24+
print("Version not found in pyproject.toml")
25+
return
26+
27+
# Rename SVG files
28+
for svg in glob.glob("benchmark_*.svg"):
29+
if not svg.startswith("benchmark_v"):
30+
# Extract timestamp from filename (e.g., benchmark_20251123_154214.svg)
31+
match = re.search(r"benchmark_(\d{8}_\d{6})\.svg", svg)
32+
if match:
33+
timestamp = match.group(1)
34+
new_name = f"benchmark_v{version}_{timestamp}.svg"
35+
else:
36+
new_name = f"benchmark_v{version}.svg"
37+
shutil.move(svg, new_name)
38+
print(f"Renamed {svg} -> {new_name}")
39+
40+
41+
if __name__ == "__main__":
42+
main()

0 commit comments

Comments
 (0)