"""Measure Argon2id hashing and verification inside the constrained app image.""" from statistics import median, quantiles from time import perf_counter from app.security import pwd_context def main(): password = "Synthetic Argon2 measurement sample" digest = pwd_context.hash(password) for name, operation in (("hash", lambda: pwd_context.hash(password)), ("verify", lambda: pwd_context.verify(digest, password))): samples = [] for _ in range(40): start = perf_counter() operation() samples.append(1000 * (perf_counter() - start)) print(f"{name}: n={len(samples)}, p50={median(samples):.2f} ms, " f"p95={quantiles(samples, n=20)[18]:.2f} ms") if __name__ == "__main__": main()