Sathvik-kota commited on
Commit
b14b760
·
verified ·
1 Parent(s): 86ca076

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. load_test_sync.py +47 -0
load_test_sync.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import asyncio
2
+ import aiohttp
3
+ import time
4
+ import random
5
+
6
+ # 🔹 Replace with your Hugging Face Space URL
7
+ ORCHESTRATOR_URL = "http://127.0.0.1:8000/ticket"
8
+ # If running locally:
9
+ # ORCHESTRATOR_URL = "http://127.0.0.1:8000/ticket"
10
+
11
+ # 25 random payloads to simulate user tickets
12
+ payloads = [
13
+ {
14
+ "channel": "web",
15
+ "severity": random.choice(["high", "low"]),
16
+ "summary": f"Test orchestrator ticket #{i}"
17
+ }
18
+ for i in range(25)
19
+ ]
20
+
21
+ async def send_request(session, idx, payload):
22
+ start = time.time()
23
+ try:
24
+ async with session.post(ORCHESTRATOR_URL, json=payload) as resp:
25
+ elapsed = time.time() - start
26
+ print(f"#{idx} → Status: {resp.status}, Time: {elapsed:.2f}s")
27
+ return resp.status, elapsed
28
+ except Exception as e:
29
+ print(f"#{idx} → Failed: {e}")
30
+ return None, 0
31
+
32
+ async def main():
33
+ print("🚀 Sending 25 concurrent requests to ORCHESTRATOR...\n")
34
+ start_time = time.time()
35
+
36
+ async with aiohttp.ClientSession() as session:
37
+ tasks = [send_request(session, i, payloads[i]) for i in range(len(payloads))]
38
+ results = await asyncio.gather(*tasks)
39
+
40
+ total_time = time.time() - start_time
41
+ success = sum(1 for s, _ in results if s == 200)
42
+ avg_time = sum(t for _, t in results if t > 0) / len(results)
43
+
44
+ print(f"\n✅ Done! Success: {success}/{len(results)} | Avg Time: {avg_time:.2f}s | Total Duration: {total_time:.2f}s")
45
+
46
+ if __name__ == "__main__":
47
+ asyncio.run(main())