|
6 | 6 |
|
7 | 7 | def generate_wrk_command_for_url(url): |
8 | 8 | # Define the command with awk included |
9 | | - return "wrk -t5 -c200 -d15s " + url |
| 9 | + return "wrk -t12 -c400 -d15s " + url |
10 | 10 |
|
11 | 11 | def wait_until_live(url): |
12 | 12 | for i in range(30): |
@@ -34,12 +34,12 @@ def extract_requests_and_latency_tuple(output): |
34 | 34 | latency_float *= 1000 |
35 | 35 | return (float(requests_sec), latency_float) |
36 | 36 | else: |
37 | | - print("Exception occurred running benchmark command:") |
| 37 | + print("Error occured running benchmark command:") |
38 | 38 | print(output.stderr.strip()) |
39 | 39 | sys.exit(1) |
40 | 40 |
|
41 | 41 | def run_benchmark(route1, route2, descriptor, percentage_limit): |
42 | | - # Make sure both routes are accessible before running benchmark |
| 42 | + # Cold start : |
43 | 43 | if not wait_until_live(route1): |
44 | 44 | raise Exception("Unable to access: " + route1) |
45 | 45 | if not wait_until_live(route2): |
@@ -72,23 +72,13 @@ def run_benchmark(route1, route2, descriptor, percentage_limit): |
72 | 72 |
|
73 | 73 | delta_in_ms = round(result_fw[1] - result_nofw[1], 2) |
74 | 74 | print(f"-> Delta in ms: {delta_in_ms}ms after running load test on {descriptor}") |
| 75 | + |
75 | 76 | delay_percentage = round( |
76 | 77 | (result_nofw[0] - result_fw[0]) / result_nofw[0] * 100 |
77 | 78 | ) |
78 | 79 | print( |
79 | 80 | f"-> {delay_percentage}% decrease in throughput after running load test on {descriptor} \n" |
80 | 81 | ) |
| 82 | + |
81 | 83 | if delay_percentage > percentage_limit: |
82 | 84 | sys.exit(1) |
83 | | - |
84 | | -# Run benchmarks : |
85 | | -run_benchmark( |
86 | | - "http://localhost:8102/delayed_route", |
87 | | - "http://localhost:8103/delayed_route", |
88 | | - "a non empty route which makes a simulated request to a database", |
89 | | - percentage_limit=15 |
90 | | -) |
91 | | -run_benchmark( |
92 | | - "http://localhost:8102/just", "http://localhost:8103/just", "an empty route", |
93 | | - percentage_limit=30 |
94 | | -) |
0 commit comments