28 lines
924 B
Bash
Executable File
28 lines
924 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
docker compose exec -T api python - <<'PY'
|
|
from argon2 import PasswordHasher
|
|
from concurrent.futures import ThreadPoolExecutor
|
|
from time import perf_counter
|
|
import json
|
|
|
|
password = "locally generated benchmark fixture"
|
|
result = {}
|
|
for memory in (19456, 24576, 32768):
|
|
h = PasswordHasher(time_cost=2, memory_cost=memory, parallelism=1)
|
|
digest = h.hash(password)
|
|
|
|
def verify(_):
|
|
start = perf_counter()
|
|
assert h.verify(digest, password)
|
|
return (perf_counter() - start) * 1000
|
|
|
|
with ThreadPoolExecutor(max_workers=2) as pool:
|
|
start = perf_counter()
|
|
samples = sorted(pool.map(verify, range(40)))
|
|
result[memory] = {"samples": len(samples), "verify_per_s": round(40/(perf_counter()-start), 1),
|
|
"p50_ms": round(samples[19], 2), "p95_ms": round(samples[37], 2)}
|
|
print(json.dumps(result, indent=2))
|
|
PY
|