Skip to content

Commit c65ef14

Browse files
committed
fixup: run with multiple valgrind versions, add bench parameters
1 parent 10e5ea2 commit c65ef14

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

.github/workflows/codspeed.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ jobs:
1515
# IMPORTANT: The binary has to match the architecture of the runner!
1616
benchmark:
1717
- testdata/take_strings-aarch64
18+
valgrind:
19+
- /usr/bin/valgrind
20+
- ../vg-in-place
1821
steps:
1922
- uses: actions/checkout@v4
2023
with:
2124
lfs: true
2225

23-
# Skip installing package docs to avoid wasting time when installing valgrind
26+
# Skip installing package docs to avoid wasting time when installing build dependencies
2427
# See: https://github.com/actions/runner-images/issues/10977#issuecomment-2810713336
2528
- name: Skip installing package docs
2629
if: runner.os == 'Linux'
@@ -32,7 +35,6 @@ jobs:
3235
EOF
3336
3437
# Build and install Valgrind
35-
#
3638
- name: Update apt-get cache
3739
run: sudo apt-get update
3840

@@ -67,11 +69,19 @@ jobs:
6769
./vg-in-place --tool=callgrind --help > /dev/null || { echo "callgrind tool not accessible!"; exit 1; }
6870
echo "Valgrind build successful and callgrind tool is accessible"
6971
72+
# Install upstream Valgrind for comparison
73+
- name: Install upstream Valgrind
74+
run: sudo apt-get install -y valgrind
75+
7076
# Setup benchmarks and run them
71-
#
7277
- name: Install uv
7378
uses: astral-sh/setup-uv@v5
7479

80+
# Ensure that the runner doesn't install it's own valgrind by linking vg-in-place to /usr/local/bin/valgrind,
81+
# which makes the version check work correctly.
82+
- name: Link vg-in-place to /usr/local/bin/valgrind
83+
run: sudo ln -sf "$PWD/vg-in-place" /usr/local/bin/valgrind
84+
7585
- name: Run the benchmarks
7686
uses: CodSpeedHQ/action@main
7787
env:
@@ -81,4 +91,4 @@ jobs:
8191
with:
8292
working-directory: bench
8393
mode: walltime
84-
run: uv run bench.py --binary-path ${{ matrix.benchmark }} --valgrind-path ${{ github.workspace }}/vg-in-place
94+
run: uv run bench.py --binary-path ${{ matrix.benchmark }} --valgrind-path ${{ matrix.valgrind }}

bench/bench.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,20 +82,32 @@ def runner(request):
8282
return request.config._valgrind_runner
8383

8484

85+
def pytest_generate_tests(metafunc):
86+
"""Parametrize tests with benchmark_id."""
87+
if "benchmark_context" in metafunc.fixturenames:
88+
runner = getattr(metafunc.config, "_valgrind_runner", None)
89+
if not runner:
90+
metafunc.parametrize("benchmark_context", ["unknown"])
91+
return
92+
93+
benchmark_id = f"{runner.binary_path.stem}, {runner.valgrind_version}"
94+
metafunc.parametrize("benchmark_context", [benchmark_id], ids=[benchmark_id])
95+
96+
8597
@pytest.mark.benchmark
86-
def test_baseline(runner):
98+
def test_baseline(runner, benchmark_context):
8799
if runner:
88100
runner.run_valgrind("--read-inline-info=no")
89101

90102

91103
@pytest.mark.benchmark
92-
def test_with_inline_info(runner):
104+
def test_with_inline_info(runner, benchmark_context):
93105
if runner:
94106
runner.run_valgrind("--read-inline-info=yes")
95107

96108

97109
@pytest.mark.benchmark
98-
def test_full_inline(runner):
110+
def test_full_inline(runner, benchmark_context):
99111
if runner:
100112
args = [
101113
"--trace-children=yes",
@@ -113,7 +125,7 @@ def test_full_inline(runner):
113125

114126

115127
@pytest.mark.benchmark
116-
def test_full(runner):
128+
def test_full(runner, benchmark_context):
117129
if runner:
118130
args = [
119131
"--trace-children=yes",

0 commit comments

Comments
 (0)