Реализовать ЛР 7 на оценку 3

This commit is contained in:
2026-12-04 14:27:18 +03:00
parent 31d441184b
commit 7996ebbb48
59 changed files with 2236 additions and 498 deletions
+30
View File
@@ -0,0 +1,30 @@
"""Compare Argon2id verification latency in the API container (synthetic input)."""
import json
from statistics import median, quantiles
from time import perf_counter
from argon2 import PasswordHasher, Type
def main() -> None:
password = 'laboratory-benchmark-synthetic-password'
for memory in (19456, 32768, 65536):
hasher = PasswordHasher(time_cost=2, memory_cost=memory, parallelism=1, type=Type.ID)
stored = hasher.hash(password)
for _ in range(3):
hasher.verify(stored, password)
samples = []
for _ in range(40):
started = perf_counter()
hasher.verify(stored, password)
samples.append((perf_counter() - started) * 1000)
print(json.dumps({
'memory_kib': memory, 'iterations': 2, 'parallelism': 1,
'samples': len(samples), 'p50_ms': round(median(samples), 2),
'p95_ms': round(quantiles(samples, n=20)[18], 2),
}))
if __name__ == '__main__':
main()