feat: complete lab 7 for grade 4
Skeleton contracts / contracts (pull_request) Blocked by required conditions

This commit is contained in:
sashadugina06
2026-12-04 13:55:32 +03:00
parent 20afc2c790
commit 11390b65fd
91 changed files with 10163 additions and 50 deletions
+28
View File
@@ -0,0 +1,28 @@
"""Measure the configured per-replica Argon2id slot budget on the app image."""
from concurrent.futures import ThreadPoolExecutor
from math import ceil
import resource
from time import perf_counter
from src.auth import hash_password, iterations, memory, parallelism, verify_password
from src.login_limits import KDF_SLOTS
def timed_verify(encoded):
started = perf_counter()
assert not verify_password(encoded, "another synthetic password")
return (perf_counter() - started) * 1000
def main():
encoded = hash_password("synthetic benchmark password")
timed_verify(encoded)
with ThreadPoolExecutor(max_workers=KDF_SLOTS) as executor:
samples = sorted(executor.map(lambda _: timed_verify(encoded), range(24)))
print(f"Argon2id memory={memory} KiB time={iterations} lanes={parallelism} slots={KDF_SLOTS} "
f"samples={len(samples)} p50={samples[11]:.1f}ms p95={samples[ceil(.95 * len(samples)) - 1]:.1f}ms "
f"peak_rss={resource.getrusage(resource.RUSAGE_SELF).ru_maxrss} KiB")
if __name__ == "__main__":
main()