import datetime as dtt import structio async def task(): for i in range(100): await structio.sleep(0.01) async def main(tests: list[int]): print("[main] Starting stress test, aggregate results will be printed at the end") results = [] for N in tests: print(f"[main] Starting test with {N} tasks") start = dtt.datetime.utcnow() async with structio.create_pool() as p: for _ in range(N): p.spawn(task) end = dtt.datetime.utcnow() results.append((end - start).total_seconds()) print(f"[main] Test with {N} tasks completed in {results[-1]:.2f} seconds") results = " ".join( (f"\n\t- {tests[i]} tasks: {r:.2f}" for i, r in enumerate(results)) ) print(f"[main] Results (values are in seconds): {results}") structio.run(main, [10, 100, 1000, 10_000])