Skip to content

Commit f14cf01

Browse files
committed
skip multithreaded benchmark test if machine is single threaded (fixes flaky github actions test, as sometimes the machines allocated are different)
1 parent 3017ccf commit f14cf01

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/test_trace_benchmarks.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import multiprocessing
12
import shutil
23
import sqlite3
34
from pathlib import Path
45

6+
import pytest
7+
58
from codeflash.benchmarking.plugin.plugin import codeflash_benchmark_plugin
69
from codeflash.benchmarking.replay_test import generate_replay_test
710
from codeflash.benchmarking.trace_benchmarks import trace_benchmarks_pytest
@@ -174,6 +177,11 @@ def test_code_to_optimize_bubble_sort_codeflash_trace_sorter():
174177
output_file.unlink(missing_ok=True)
175178
shutil.rmtree(replay_tests_dir)
176179

180+
# Skip the test if the machine has only 1 thread/CPU
181+
@pytest.mark.skipif(
182+
multiprocessing.cpu_count() <= 1,
183+
reason="This test requires more than 1 CPU thread"
184+
)
177185
def test_trace_multithreaded_benchmark() -> None:
178186
project_root = Path(__file__).parent.parent / "code_to_optimize"
179187
benchmarks_root = project_root / "tests" / "pytest" / "benchmarks_multithread"

0 commit comments

Comments
 (0)