diff options
author | Mattias Andrée <maandree@kth.se> | 2022-02-16 16:11:36 +0100 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2022-02-16 16:11:36 +0100 |
commit | d6f303ab33bdb97fa50a7daba6d4fa489a9feca2 (patch) | |
tree | b36af440b4d97d7b13dc49683168c4fc18dbe463 /test.c | |
parent | Fix style + minimal optimisation (diff) | |
download | libar2-d6f303ab33bdb97fa50a7daba6d4fa489a9feca2.tar.gz libar2-d6f303ab33bdb97fa50a7daba6d4fa489a9feca2.tar.bz2 libar2-d6f303ab33bdb97fa50a7daba6d4fa489a9feca2.tar.xz |
Small optimisation for little-endian machines
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to '')
-rw-r--r-- | test.c | 39 |
1 files changed, 38 insertions, 1 deletions
@@ -1,6 +1,15 @@ /* See LICENSE file for copyright and license details. */ #include "common.h" + +#ifndef MEASURE_TIME +# define MEASURE_TIME 0 +#endif + #include <stdlib.h> +#if MEASURE_TIME +# include <stdio.h> +# include <time.h> +#endif #define MEM(S) S, sizeof(S) - 1 @@ -845,6 +854,7 @@ check_libar2_hash_buf_size(void) int main(void) { +#if 1 check_libar2_type_to_string(); check_libar2_string_to_type(); check_libar2_version_to_string(); @@ -856,8 +866,35 @@ main(void) check_libar2_validate_params(); check_libar2_hash(); -#ifdef LIBAR2_WEAKLY_LINKED__ +# ifdef LIBAR2_WEAKLY_LINKED__ check_libar2_hash_buf_size(); +# endif +#endif + +#if MEASURE_TIME + { + struct libar2_argon2_parameters params; + char output[512]; + clock_t dur; + double ddur; + int r; + memset(¶ms, 0, sizeof(params)); + params.m_cost = (uint_least32_t)1 << 18; + params.t_cost = 1; + params.lanes = 1; + params.saltlen = 8; + params.salt = (unsigned char[]){"\0\0\0\0\0\0\0\0"}; + params.hashlen = 32; + assert(!libar2_validate_params(¶ms, NULL)); + dur = clock(); + r = libar2_hash(output, NULL, 0, ¶ms, &ctx_st); + dur = clock() - dur; + assert(!r); + ddur = (double)dur; + ddur /= CLOCKS_PER_SEC; + ddur *= 1000; + fprintf(stderr, "Time: %lg ms\n", ddur); + } #endif return 0; |