Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Measure the streaming stripper against CPU time, not wall clock (#9035)
Daniel Han803060737440
diff --git a/studio/backend/tests/test_streaming_stripper.py b/studio/backend/tests/test_streaming_stripper.pyindex 833f96ee61b..e48015c58ff 100644--- a/studio/backend/tests/test_streaming_stripper.py+++ b/studio/backend/tests/test_streaming_stripper.py@@ -454,17 +454,34 @@ def test_early_markup_is_not_slower_than_the_code_it_replaces():prefix = '`x` <tool_call>{"name": "search", "arguments": {}}</tool_call> 'def elapsed(fn, count):+ # process_time, not perf_counter: this compares how much work two code paths do,+ # and wall clock also measures whatever else the machine is running. A 10% margin+ # does not survive that. On a 4-vCPU CI runner with other test workers in flight+ # the wall-clock version failed outright (1.451s against 1.316s) while the code+ # under test had not changed. CPU time of this process is the quantity the+ # assertion is actually about, and it is unaffected by neighbours.text = prefix- start = time.perf_counter()+ start = time.process_time()for _ in range(count):text += "word "fn(text)- return time.perf_counter() - start+ return time.process_time() - startcount = 1500reference = min(elapsed(_reference_strip, count) for _ in range(3))incremental = min(elapsed(StreamingMarkupStripper(ENABLED).strip, count) for _ in range(3))+ # process_time has coarser granularity than perf_counter, and `0.0 <= 0.0 * 1.10` is+ # true. Without a floor a clock that stopped reporting, or a `count` someone lowered,+ # turns this into an assertion that cannot fail. 0.05s is far below the ~1.3s each arm+ # actually takes and far above the clock's resolution.+ assert (+ reference > 0.05+ ), f"reference arm measured {reference:.4f}s; too small to compare against"+ assert (+ incremental > 0.05+ ), f"incremental arm measured {incremental:.4f}s; too small to compare against"+assert (incremental <= reference * 1.10), f"early markup cost {incremental:.3f}s against the reference's {reference:.3f}s"