aboutsummaryrefslogtreecommitdiffstats
path: root/test.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-02-16 16:11:36 +0100
committerMattias Andrée <maandree@kth.se>2022-02-16 16:11:36 +0100
commitd6f303ab33bdb97fa50a7daba6d4fa489a9feca2 (patch)
treeb36af440b4d97d7b13dc49683168c4fc18dbe463 /test.c
parentFix style + minimal optimisation (diff)
downloadlibar2-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.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/test.c b/test.c
index 9a9b3f7..c9f7b5a 100644
--- a/test.c
+++ b/test.c
@@ -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(&params, 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(&params, NULL));
+ dur = clock();
+ r = libar2_hash(output, NULL, 0, &params, &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;