diff options
author | Mattias Andrée <maandree@kth.se> | 2024-09-11 21:54:30 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2024-09-11 21:54:30 +0200 |
commit | c966c39d9c0352ccb48469f68fb57c1d13dce4c7 (patch) | |
tree | 35ef69fea2533d979042c5d25e8ddb419f74b56c /libhashsum_init_keccak__.c | |
parent | m doc (diff) | |
download | libhashsum-c966c39d9c0352ccb48469f68fb57c1d13dce4c7.tar.gz libhashsum-c966c39d9c0352ccb48469f68fb57c1d13dce4c7.tar.bz2 libhashsum-c966c39d9c0352ccb48469f68fb57c1d13dce4c7.tar.xz |
Add relative_performance
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | libhashsum_init_keccak__.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/libhashsum_init_keccak__.c b/libhashsum_init_keccak__.c index f9c8be1..53a9e52 100644 --- a/libhashsum_init_keccak__.c +++ b/libhashsum_init_keccak__.c @@ -140,6 +140,25 @@ destroy(struct libhashsum_hasher *this) } +static uint64_t +estimate_performance(long int r, long int c) +{ + uint64_t base = 22517998136852480ULL / (uint64_t)r; + switch (r + c) { + case 1600: + return base / 368ULL; + case 800: + return base / 2042ULL; + case 400: + return base / 1858ULL; + case 200: + return base / 1747ULL; + default: + return 0; + } +} + + int libhashsum_init_keccak__(struct libhashsum_hasher *this, size_t hashbits, void *spec_, size_t squeezes, const char *suffix) { @@ -170,6 +189,7 @@ libhashsum_init_keccak__(struct libhashsum_hasher *this, size_t hashbits, void * } this->input_block_size = libkeccak_zerocopy_chunksize(&this->state.keccak.s); + this->relative_performance = estimate_performance(spec->bitrate, spec->capacity); this->process = &process; this->finalise_const = &finalise_const; this->finalise = &finalise; |