26 lines
894 B
Python
26 lines
894 B
Python
import json
|
|
import resource
|
|
import statistics
|
|
import time
|
|
|
|
from argon2 import PasswordHasher, Type
|
|
|
|
|
|
if __name__ == "__main__":
|
|
hasher = PasswordHasher(time_cost=2, memory_cost=19456, parallelism=1, type=Type.ID)
|
|
samples = []
|
|
for _ in range(20):
|
|
started = time.perf_counter()
|
|
value = hasher.hash("Synthetic benchmark password")
|
|
hasher.verify(value, "Synthetic benchmark password")
|
|
samples.append(time.perf_counter() - started)
|
|
ordered = sorted(samples)
|
|
print(json.dumps({
|
|
"samples": len(samples), "operation": "hash_plus_verify", "memory_kib": 19456,
|
|
"time_cost": 2, "parallelism": 1,
|
|
"p50_seconds": round(statistics.median(samples), 4),
|
|
"p95_seconds": round(ordered[18], 4),
|
|
"peak_rss_bytes": resource.getrusage(resource.RUSAGE_SELF).ru_maxrss * 1024,
|
|
"server_max_parallel_hashes": 2,
|
|
}))
|