Skip to content

Commit 9c474db

Browse files
Improvements for history run
1 parent 50f7ea1 commit 9c474db

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

.github/workflows/perfhistory.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,15 @@ on:
1919
commits:
2020
description: "List of commits or tags to benchmark (space-separated)"
2121
required: true
22-
default: "v2.0.1 v2.2.0 v2.3.0"
22+
default: "v2.0.1 v2.2.0 v2.3.0 current"
23+
memory:
24+
description: "Include memory benchmark (Y|N). Time consuming."
25+
required: true
26+
default: "N"
2327

2428
env:
25-
DEFAULT_COMMITS: "v2.0.1 v2.2.0 v2.3.0"
29+
DEFAULT_MEMORY: "N"
30+
DEFAULT_COMMITS: "v2.0.1 v2.2.0 v2.3.0 current"
2631

2732
jobs:
2833
perf-tests:
@@ -69,11 +74,20 @@ jobs:
6974
- name: Run benchmark
7075
shell: bash
7176
env:
77+
MEMORY: ${{ github.event.inputs.memory || env.DEFAULT_MEMORY }}
7278
COMMITS: ${{ github.event.inputs.commits || env.DEFAULT_COMMITS }}
7379
run: |
80+
7481
echo "Running benchmarks for commits: $COMMITS"
7582
export PYTHONPATH="."
76-
python perf/historyrun.py --commits $COMMITS --times 3
83+
84+
if [ $MEMORY == "Y" ]; then
85+
echo "➔ Including memory benchmarks 🟢"
86+
python perf/historyrun.py --commits $COMMITS --times 3 --memory
87+
else
88+
echo "➔ Excluding memory benchmarks 🔴"
89+
python perf/historyrun.py --commits $COMMITS --times 3 --no-memory
90+
fi
7791
7892
- name: Upload results
7993
uses: actions/upload-artifact@v4

perf/historyrun.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def make_compile():
8686
subprocess.check_output(["make", "compile"], universal_newlines=True)
8787

8888

89-
def run_tests(iterations: int, output_dir: str, times: int):
89+
def run_tests(iterations: int, output_dir: str, times: int, memory: bool):
9090
subprocess.check_output(
9191
[
9292
"python",
@@ -97,6 +97,7 @@ def run_tests(iterations: int, output_dir: str, times: int):
9797
output_dir,
9898
"--times",
9999
str(times),
100+
"--memory" if memory else "--no-memory",
100101
],
101102
universal_newlines=True,
102103
)
@@ -142,6 +143,12 @@ def main():
142143
nargs="+", # Accept one or more commit SHAs
143144
help="List of Git commit SHAs to benchmark",
144145
)
146+
parser.add_argument(
147+
"--memory",
148+
default=True,
149+
action=argparse.BooleanOptionalAction,
150+
help="Includes or skips memory benchmarks (included by default)",
151+
)
145152
args = parser.parse_args()
146153

147154
# Example usage of the commits argument
@@ -155,15 +162,17 @@ def main():
155162
output_dir = Path(temp_dir) / "results"
156163
copy_perf_code(temp_dir)
157164

158-
with gitcontext():
165+
with gitcontext() as current_branch:
159166
for commit in args.commits:
167+
if commit.lower() in {"current", "last", "head"}:
168+
commit = current_branch
160169
subprocess.check_output(
161170
["git", "checkout", "-f", commit], universal_newlines=True
162171
)
163172
logger.info("Checked out commit: %s", commit)
164173
make_compile()
165174
restore_perf_code(temp_dir)
166-
run_tests(args.iterations, str(output_dir), args.times)
175+
run_tests(args.iterations, str(output_dir), args.times, args.memory)
167176

168177
# Copy the results from output_dir to ./benchmark_results
169178
copy_results(str(output_dir), "./benchmark_results")

perf/main.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def get_system_info():
132132
}
133133

134134

135-
async def run_all_benchmarks(iterations: int, key: str, no_memory: bool):
135+
async def run_all_benchmarks(iterations: int, key: str, memory: bool):
136136
results = {
137137
"timestamp": datetime.now().isoformat(),
138138
"git_info": get_git_info(),
@@ -156,7 +156,7 @@ async def run_all_benchmarks(iterations: int, key: str, no_memory: bool):
156156
else:
157157
results["benchmarks"][name] = func(iterations)
158158

159-
if no_memory:
159+
if memory is False:
160160
return results
161161

162162
# Memory benchmarks
@@ -205,14 +205,15 @@ def save_results(results, output_dir="./benchmark_results"):
205205
help="Optional filter to run specific benchmarks",
206206
)
207207
parser.add_argument(
208-
"--no-memory",
209-
action="store_true",
210-
help="If set, skips memory benchmarks",
208+
"--memory",
209+
default=True,
210+
action=argparse.BooleanOptionalAction,
211+
help="Includes or skips memory benchmarks (included by default)",
211212
)
212213
args = parser.parse_args()
213214

214215
for _ in range(args.times):
215216
results = asyncio.run(
216-
run_all_benchmarks(args.iterations, args.filter, args.no_memory)
217+
run_all_benchmarks(args.iterations, args.filter, args.memory)
217218
)
218219
save_results(results, args.output_dir)

0 commit comments

Comments
 (0)