Update concurrency benchmarks code

This commit is contained in:
Giovanni Barillari 2024-03-19 00:00:17 +01:00
parent 327573f95e
commit a19b68469f
No known key found for this signature in database
2 changed files with 37 additions and 9 deletions

View file

@ -82,14 +82,22 @@ Python version: {{ =data.pyver }}
{{ for interface in ["asgi", "rsgi", "wsgi"]: }}
### {{ =interface.upper() }}
{{ max_rps = {"runtime": 0, "workers": 0} }}
{{ for runs in data.results["concurrencies"][interface].values(): }}
{{ for crun in runs["res"].values(): }}
{{ max_rps[runs["m"]] = max(crun["requests"]["rps"], max_rps[runs["m"]]) }}
{{ pass }}
{{ pass }}
{{ pass }}
| Concurrency | Total requests | RPS | avg latency | max latency |
| --- | --- | --- | --- | --- |
{{ for key, runs in data.results["concurrencies"][interface].items(): }}
{{ concurrency_values = {runs[ckey]["requests"]["rps"]: ckey for ckey in runs.keys()} }}
| Mode | Processes | Threads | Blocking Threads | Total requests | RPS | avg latency | max latency |
| --- | --- | --- | --- | --- | --- | --- | --- |
{{ for runs in data.results["concurrencies"][interface].values(): }}
{{ concurrency_values = {runs["res"][ckey]["requests"]["rps"]: ckey for ckey in runs["res"].keys()} }}
{{ max_res = concurrency_values[max(concurrency_values.keys())] }}
{{ run = runs[max_res] }}
| {{ =key }} (c{{ =max_res }}) | {{ =run["requests"]["total"] }} | {{ =run["requests"]["rps"] }} | {{ =int(run["latency"]["avg"]) / 1000 }}ms | {{ =int(run["latency"]["max"]) / 1000 }}ms |
{{ run = runs["res"][max_res] }}
{{ rps = "**" + run["requests"]["rps"] + "**" if run["requests"]["rps"] == max_rps[runs["m"]] else run["requests"]["rps"] }}
| {{ =runs["m"] }} (c{{ =max_res }}) | {{ =runs["p"] }} | {{ =runs["t"] }} | {{ =runs["b"] }} | {{ =run["requests"]["total"] }} | {{ =rps }} | {{ =int(run["latency"]["avg"]) / 1000 }}ms | {{ =int(run["latency"]["max"]) / 1000 }}ms |
{{ pass }}
{{ pass }}

View file

@ -94,8 +94,8 @@ def benchmark(endpoint, post=False):
def concurrencies():
nperm = sorted(set([1, 2, round(CPU / 2.5), round(CPU / 2), CPU]))
results = {}
for interface in ["asgi", "rsgi", "wsgi"]:
results = {"wsgi": {}}
for interface in ["asgi", "rsgi"]:
results[interface] = {}
for np in nperm:
for nt in [1, 2, 4]:
@ -103,7 +103,27 @@ def concurrencies():
key = f"P{np} T{nt} {threading_mode[0]}th"
with app(interface, np, nt, threading_mode):
print(f"Bench concurrencies - [{interface}] {threading_mode} {np}:{nt}")
results[interface][key] = benchmark("b")
results[interface][key] = {
"m": threading_mode,
"p": np,
"t": nt,
"b": 1,
"res": benchmark("b")
}
for np in nperm:
for nt in [1, 2, 4]:
for nbt in [1, 2, 4]:
for threading_mode in ["workers", "runtime"]:
key = f"P{np} T{nt} B{nbt} {threading_mode[0]}th"
with app("wsgi", np, nt, threading_mode):
print(f"Bench concurrencies - [wsgi] {threading_mode} {np}:{nt}:{nbt}")
results["wsgi"][key] = {
"m": threading_mode,
"p": np,
"t": nt,
"b": nbt,
"res": benchmark("b")
}
return results