Last active
June 4, 2024 13:41
-
-
Save danielSanchezQ/dce309a9ef488b5bcfaad1869f538702 to your computer and use it in GitHub Desktop.
NomosDa benches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import defaultdict | |
from math import ceil | |
benches_results = { | |
"proofs": { | |
128: 0.28, | |
256: 0.47, | |
512: 0.82, | |
1024: 1.39 | |
}, | |
"proofs_single": { | |
128: 0.73, | |
256: 1.15, | |
512: 1.77, | |
1024: 2.65 | |
}, | |
"proofs_fk20": { | |
128: 2.3, | |
256: 1.22, | |
512: 0.63, | |
1024: 0.31, | |
2048: 0.19, | |
4096: 0.125, | |
}, | |
"proofs_fk20_single": { | |
128: 16.7, | |
256: 8.5, | |
512: 4.44, | |
1024: 2.3, | |
2048: 1.38, | |
4096: 0.89, | |
}, | |
"commitments_single": { | |
16: 0.29, | |
32: 0.34, | |
64: 0.41, | |
128: 0.58, | |
256: 1.0, | |
512: 1.42, | |
1024: 2.22, | |
2048: 4.04, | |
4096: 7.6, | |
}, | |
"commitments": { | |
16: 0.10, | |
32: 0.14, | |
64: 0.21, | |
128: 0.31, | |
256: 0.51, | |
512: 0.90, | |
1024: 1.48, | |
2048: 2.66, | |
4096: 4.85, | |
}, | |
"verification": defaultdict(lambda: 1.8) | |
} | |
BYTES_PER_CHUNK: int = 31 | |
def compute_times(tag, number_of_columns, number_to_compute) -> int: | |
average_time = benches_results[tag][number_of_columns] | |
return average_time * number_to_compute | |
def chunks_by_size(size) -> int: | |
return int(ceil(size / BYTES_PER_CHUNK)) | |
def commitments_by_size_and_columns(size, columns) -> int: | |
return int(ceil(chunks_by_size(size) / columns)) | |
def column_commitments_by_columns_and_row_commitments(tag, columns, degree) -> int: | |
commitments_times = benches_results[tag] | |
if degree > max(commitments_times.keys()): | |
key = max(commitments_times.keys()) | |
else: | |
key = next(x for x in sorted(commitments_times.keys()) if x >= degree) | |
return columns * commitments_times[key] | |
def verification_time(tag, number_of_proofs, columns) -> int: | |
return benches_results[tag][columns] + number_of_proofs * benches_results["verification"][columns] | |
if __name__ == "__main__": | |
from itertools import product | |
columns = [128, 256, 512, 1024, 2048, 4096] | |
sizes = [32, 64, 128, 256, 512, 1024] | |
kb_to_b = 1024 | |
for bench in ["proofs", "proofs_single", "proofs_fk20", "proofs_fk20_single"]: | |
print(bench) | |
commitments_tag = "commitments" if not bench.endswith("single") else "commitments_single" | |
for size, column in product(sizes, columns): | |
if column not in benches_results[bench]: | |
continue | |
commitments = commitments_by_size_and_columns(size*kb_to_b, column) | |
proofs = chunks_by_size(size*kb_to_b) | |
commitments_time = compute_times(commitments_tag, column, commitments) | |
proofs_time = compute_times(bench, column, proofs) | |
_verification_time = verification_time(commitments_tag, commitments, column) | |
columns_commitments_time = column_commitments_by_columns_and_row_commitments(tag=commitments_tag, columns=column, degree=commitments) | |
print(f"Columns={column:>4}, Size={size:>4}Kb, Commitments={commitments:>4} in {commitments_time:>10.2f}ms, Proofs={proofs:>8} in {proofs_time:>12.2f}ms, ColumnCommitments={column:>8} in {columns_commitments_time:>10.2f}ms, Verification=1 Commit and {commitments:>4} Proofs in {_verification_time:>12.2f}ms") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment