From c966c39d9c0352ccb48469f68fb57c1d13dce4c7 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 11 Sep 2024 21:54:30 +0200 Subject: Add relative_performance MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- libhashsum_init_keccak__.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libhashsum_init_keccak__.c') 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; -- cgit v1.2.3-70-g09d2