Skip to content

Commit aedd97a

Browse files
committed
set seed via --randomly-seed
1 parent 736505e commit aedd97a

2 files changed

Lines changed: 8 additions & 13 deletions

File tree

‎.github/workflows/codspeed.yml‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ env:
1818
# cross-run variance. See:
1919
# https://codspeed.io/blog/why-glibc-faster-github-actions#how-to-fix-it-
2020
GLIBC_TUNABLES: "glibc.cpu.hwcaps=-AVX512F,-AVX512DQ,-AVX512_VBMI2,-AVX2,-AVX,-ERMS,-FSRM"
21+
RANDOMLY_SEED: "3485796098"
2122

2223
jobs:
2324
amd_benchmarks:
@@ -50,7 +51,7 @@ jobs:
5051
uses: CodSpeedHQ/action@c145068895e045cc725ee76fcd2307624b65c3af # v4.17.5
5152
with:
5253
mode: simulation
53-
run: uv run --no-sync pytest tests/prof/perf --codspeed -k amd
54+
run: uv run --no-sync pytest tests/prof/perf --randomly-seed="$RANDOMLY_SEED" --codspeed -k amd
5455

5556
arm_benchmarks:
5657
name: arm benchmarks
@@ -82,7 +83,7 @@ jobs:
8283
uses: CodSpeedHQ/action@c145068895e045cc725ee76fcd2307624b65c3af # v4.17.5
8384
with:
8485
mode: simulation
85-
run: uv run --no-sync pytest tests/prof/perf --codspeed -k arm
86+
run: uv run --no-sync pytest tests/prof/perf --codspeed --randomly-seed="$RANDOMLY_SEED" -k arm
8687

8788
memory_benchmarks:
8889
name: Memory benchmarks
@@ -114,4 +115,4 @@ jobs:
114115
uses: CodSpeedHQ/action@c145068895e045cc725ee76fcd2307624b65c3af # v4.17.5
115116
with:
116117
mode: memory
117-
run: uv run --no-sync pytest tests/prof/perf --codspeed -k amd -m memory
118+
run: uv run --no-sync pytest tests/prof/perf --randomly-seed="$RANDOMLY_SEED" --codspeed -k amd -m memory

‎tests/prof/perf/test_structs.py‎

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ class C{n}(Struct, order=True, tag_field="my_tag_field"):
4646
N = 1000
4747

4848

49-
@pytest.fixture()
50-
def _random() -> random.Random:
51-
# new random instance with a fixed seed to reduce variance between runs
52-
return random.Random(b"}\xf7\xab\xcc4\xec\x1d%j\xc1")
53-
54-
5549
class Item(msgspec.Struct, order=True):
5650
a: int
5751
b: int
@@ -116,16 +110,16 @@ def test_create(benchmark):
116110

117111

118112
@pytest.mark.memory
119-
def test_equality(benchmark, _random):
113+
def test_equality(benchmark):
120114
needle = Item(N - 1, N - 1, N - 1, N - 1, N - 1)
121115
haystack = [Item(i, i, i, i, i) for i in range(N)]
122-
_random.shuffle(haystack)
116+
random.shuffle(haystack)
123117
benchmark(haystack.index, needle)
124118

125119

126120
@pytest.mark.memory
127-
def test_order(benchmark: BenchmarkFixture, _random):
121+
def test_order(benchmark: BenchmarkFixture):
128122
haystack = [Item(i, i, i, i, i) for i in range(N)]
129-
_random.shuffle(haystack)
123+
random.shuffle(haystack)
130124

131125
benchmark(sorted, haystack)

0 commit comments

Comments
 (0)