Download flysim/tests/test_speed.py from nynefold/flysim-malecns: direct link, hf CLI and curl.
- Browser
- Download file 1.73 kB
-
https://huggingface.co/datasets/nynefold/flysim-malecns/resolve/main/flysim/tests/test_speed.py
- Command line
-
hf download hf://datasets/nynefold/flysim-malecns/flysim/tests/test_speed.py
-
curl -L -o test_speed.py https://huggingface.co/datasets/nynefold/flysim-malecns/resolve/main/flysim/tests/test_speed.py
1.73 kB
| """Speed-benchmark harness (preregistration, section 6): report and live-default rule | |
| (no timing run).""" | |
| import pytest | |
| from flysim.validation import speed as sp | |
| def _r(variant, stimulus, rate, median, mx=None): | |
| return {"variant": variant, "stimulus": stimulus, "rate": rate, "key": "k", | |
| "median_per_sim_s": median, "max_per_sim_s": mx or median, "spikes": 1000, | |
| "peak_rss_mb": 500.0} | |
| def test_live_default_averages_the_three_chains_at_100_hz(): | |
| res = [_r("full", s, 100.0, m) for s, m in (("LC4", 6.0), ("LC16", 4.0), ("LC9", 5.0))] | |
| res += [_r("full", "LC16+LPLC1+LPLC2", 100.0, 99.0), _r("full", "LC4", 200.0, 99.0)] | |
| best, means = sp.live_default(res) | |
| assert best == "full" and means == {"full": pytest.approx(5.0)} | |
| def test_live_default_tie_goes_to_the_less_culled(): | |
| res = [_r(v, s, 100.0, 5.0) for v in ("min3", "full") for s in sp.DEFAULT_CHAINS] | |
| assert sp.live_default(res)[0] == "full" | |
| res = [_r("min3", s, 100.0, 4.0) for s in sp.DEFAULT_CHAINS] + res[3:] | |
| assert sp.live_default(res)[0] == "min3" | |
| def test_report_names_label_and_ratio(): | |
| d = {"label": "Provisional", "warmup": 1, "repeats": 5, | |
| "hardware": {"cpu": "X", "cores": 4, "ram_gb": 16, "os": "Linux", "python": "3.13", | |
| "numpy": "2", "numba": "0.6"}, | |
| "results": [_r("full", s, 100.0, 5.0, 6.0) for s in sp.DEFAULT_CHAINS]} | |
| md = sp.render(d) | |
| assert "**Provisional.**" in md and "→ `full`" in md and "at least 6.0×" in md | |
| def test_one_thread_env_and_task_list(): | |
| assert sp.ONE_THREAD["NUMBA_NUM_THREADS"] == "1" | |
| assert sp.LIVE_VARIANTS == ("full",) and sp.RATES == (25.0, 100.0, 200.0) | |
| assert pytest.approx(0.6) == sp.SIM_S | |