Эндпоинт подбора числа потоков

Масштабирование ONNX зависит от процессора: замеры на Apple M4 не
переносятся на Ryzen, а подбирать конфигурацию перезапусками мучительно.
Теперь /v1/benchmark гоняет минуту записи на 1, 2, 4, 8 и 16 потоках
и говорит, что поставить в config.toml.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Vladimir Bryzgalov
2026-08-15 23:01:55 +05:00
co-authored by Claude Opus 5
parent c1ba61fcd5
commit 42a98bd703
4 changed files with 112 additions and 1 deletions
+23
View File
@@ -135,3 +135,26 @@ class TestLazyWarmup:
assert "warmup" not in str(exc)
except Exception:
pass
class TestBenchmarkEndpoint:
def test_benchmark_requires_token(self, tmp_path, monkeypatch):
import sys
import types
from fastapi.testclient import TestClient
config = tmp_path / "config.toml"
config.write_text('[security]\ntoken="t"\nallow_ips=""\n', encoding="utf-8")
monkeypatch.setenv("TALKSCORE_ASR_HOME", str(tmp_path))
for name in ("sherpa_onnx", "onnx_asr", "onnxruntime"):
monkeypatch.setitem(sys.modules, name, types.ModuleType(name))
for mod in [m for m in list(sys.modules) if m.startswith("app.")]:
del sys.modules[mod]
import app.config as cfg
monkeypatch.setattr(cfg, "BASE_DIR", tmp_path)
import app.main as main
main._worker_stop.set()
with TestClient(main.app) as c:
assert c.post("/v1/benchmark", files={"file": ("a.wav", b"x")}).status_code == 401