MCPcopy Index your code
hub / github.com/idank/explainshell / _fire_one

Function _fire_one

tools/loadtest.py:239–277  ·  view source on GitHub ↗
(
    session,
    url: str,
    rng: random.Random,
    results: list[Result],
    test_start: float,
    simple_ratio: float,
)

Source from the content-addressed store, hash-verified

237
238
239async def _fire_one(
240 session,
241 url: str,
242 rng: random.Random,
243 results: list[Result],
244 test_start: float,
245 simple_ratio: float,
246) -> None:
247 if rng.random() < simple_ratio:
248 cmd = rng.choice(SIMPLE_CMDS)
249 else:
250 cmd = gen_bot_cmd(rng)
251 target = f"{url}/explain"
252 t0 = time.perf_counter()
253 try:
254 async with session.get(target, params={"cmd": cmd}, timeout=60) as resp:
255 body = await resp.read()
256 lat = (time.perf_counter() - t0) * 1000.0
257 results.append(
258 Result(
259 ok=resp.status == 200,
260 status=resp.status,
261 latency_ms=lat,
262 bytes=len(body),
263 t_end_s=time.monotonic() - test_start,
264 )
265 )
266 except Exception as e:
267 lat = (time.perf_counter() - t0) * 1000.0
268 results.append(
269 Result(
270 ok=False,
271 status=0,
272 latency_ms=lat,
273 bytes=0,
274 t_end_s=time.monotonic() - test_start,
275 err=str(e)[:80],
276 )
277 )
278
279
280async def _closed_loop_worker(

Callers 2

_closed_loop_workerFunction · 0.85
_open_loop_schedulerFunction · 0.85

Calls 2

gen_bot_cmdFunction · 0.85
ResultClass · 0.85

Tested by

no test coverage detected