-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_quick.py
More file actions
50 lines (43 loc) · 1.22 KB
/
Copy pathtest_quick.py
File metadata and controls
50 lines (43 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import time
import tui_tester
print("Testing LoadGenerator...")
print()
# Create LoadGenerator
gen = tui_tester.LoadGenerator(
url="https://httpbin.org/get",
concurrency=2
)
print(f"Created LoadGenerator for https://httpbin.org/get")
print(f"Concurrency: 2 threads")
print(f"Running: {gen.is_running()}")
print()
# Start
gen.start()
print("Started load generator...")
print(f"Running: {gen.is_running()}")
print()
# Run for 5 seconds
for i in range(5):
time.sleep(1)
stats = gen.get_stats()
print(f"[{i+1}s] Requests: {stats.request_count}, "
f"Errors: {stats.error_count}, "
f"RPS: {stats.rps:.2f}, "
f"Avg Latency: {stats.avg_latency_ms:.2f}ms")
# Stop
gen.stop()
print()
print("Stopped load generator")
print(f"Running: {gen.is_running()}")
print()
# Final stats
final_stats = gen.get_stats()
print("Final Statistics:")
print(f" Total Requests: {final_stats.request_count}")
print(f" Errors: {final_stats.error_count}")
print(f" Avg Latency: {final_stats.avg_latency_ms:.2f}ms")
print(f" Min Latency: {final_stats.min_latency_ms:.2f}ms")
print(f" Max Latency: {final_stats.max_latency_ms:.2f}ms")
print(f" RPS: {final_stats.rps:.2f}")
print()
print("✓ Test completed successfully!")