Skip to content

Commit

Permalink
🧐 Add async test script
Browse files Browse the repository at this point in the history
  • Loading branch information
simonwoerpel committed Nov 29, 2024
1 parent 94077d6 commit 12c8c5b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions async_ddos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import asyncio

import requests
from codetiming import Timer

URL = "http://localhost:8000/entities?schema=Membership&nested=1&page={i}&limit=100"


async def task(i):
with Timer(text=f"Page {i} elapsed time: {{:.1f}}"):
res = requests.get(URL.format(i=i))
assert res.ok


async def main():
tasks = [asyncio.create_task(task(i)) for i in range(1, 100)]
await asyncio.gather(*tasks)


if __name__ == "__main__":
asyncio.run(main())

0 comments on commit 12c8c5b

Please sign in to comment.