Browse Source

Uniformous exp_bench mul_bench and ddlog_bench.

Michele Orrù 7 years ago
parent
commit
8973e1845e
5 changed files with 15 additions and 10 deletions
  1. 3 3
      src/Makefile.am
  2. 2 1
      src/ddlog_bench.c
  3. 5 3
      src/exp_bench.c
  4. 0 0
      src/group_bench.c
  5. 5 3
      src/rms_bench.c

+ 3 - 3
src/Makefile.am

@@ -1,4 +1,4 @@
-BENCHMARKS = rms_bench ddlog_bench exp_bench mul_bench
+BENCHMARKS = rms_bench ddlog_bench exp_bench group_bench
 
 bin_PROGRAMS = $(BENCHMARKS) sanity_check
 check_PROGRAMS = group_test ddlog_test
@@ -23,9 +23,9 @@ ddlog_bench_SOURCES = ddlog_bench.c \
 	$(DDLOG) $(ENTROPY) $(GROUP) $(TIMEIT)
 exp_bench_SOURCES = exp_bench.c \
 	$(ENTROPY) $(GROUP) $(FBASE) $(TIMEIT)
-mul_bench_SOURCES = mul_bench.c \
+group_bench_SOURCES = group_bench.c \
 	$(ENTROPY) $(GROUP)
-mul_bench_LDADD = -lcrypto -lssl
+group_bench_LDADD = -lcrypto -lssl
 
 sanity_check_SOURCES = sanity_check.c \
 	$(DDLOG) $(ELGAMAL) $(ENTROPY) $(GROUP) $(FBASE) $(HSS) $(TIMEIT)

+ 2 - 1
src/ddlog_bench.c

@@ -16,7 +16,8 @@ int main()
   dlog_precompute();
   mpz_entropy_init();
 
-  for (int i=0; i < (int) (0x01 << 16); i++) {
+  const int repeat = (0x01 << FAILURE) * 3;
+  for (int i=0; i < repeat; i++) {
     mpz_t n;
     mpz_init(n);
 

+ 5 - 3
src/exp_bench.c

@@ -1,3 +1,5 @@
+#include "config.h"
+
 #include <assert.h>
 #include <stdio.h>
 
@@ -31,8 +33,9 @@ int main()
   fbase_ptr pbase = fb_init();
   fb_set(pbase, base);
 
-  INIT_TIMEIT(CLOCK_PROCESS_CPUTIME_ID);
   for (int i = 0; i < (int) 1e4; i++) {
+    INIT_TIMEIT(CLOCK_PROCESS_CPUTIME_ID);
+
     getrandom(&exp, 8, GRND_NONBLOCK);
 
     mpz_powm_ui(expected, base, exp, p);
@@ -41,11 +44,10 @@ int main()
     END_TIMEIT();
 
     assert(!mpz_cmp(test, expected));
-
+    printf("%d" SEP TIMEIT_FORMAT "\n", FB_BASE, GET_TIMEIT());
   }
 
 
-  printf(TIMEIT_FORMAT "\n", GET_TIMEIT());
   fb_clear(pbase);
   mpz_clears(test, expected, base, NULL);
 }

src/mul_bench.c → src/group_bench.c


+ 5 - 3
src/rms_bench.c

@@ -9,8 +9,6 @@
 #include "hss.h"
 #include "timeit.h"
 
-INIT_TIMEIT(CLOCK_PROCESS_CPUTIME_ID);
-
 
 int main()
 {
@@ -65,6 +63,8 @@ int main()
 
 
   for (int i = 0; i <  (int) 1e2; i++) {
+    INIT_TIMEIT(CLOCK_PROCESS_CPUTIME_ID);
+
     START_TIMEIT();
     hss_mul(t1, r1, s1);
     END_TIMEIT();
@@ -83,9 +83,11 @@ int main()
     mpz_abs(test, test);
     assert(((!mpz_cmp_ui(xy, 1) && !mpz_cmp(test, key->sk))) ||
            ((!mpz_cmp_ui(xy, 0)) && !mpz_cmp_ui(test, 0)));
+
+    printf("%d" SEP  "%d" SEP "%d" SEP TIMEIT_FORMAT "\n",
+           FAILURE, FB_BASE, SS_BASE, GET_TIMEIT());
   }
 
-  printf(TIMEIT_FORMAT "\n", GET_TIMEIT());
   ssl2_clear(s1);
   ssl2_clear(s2);
   ssl1_clear(r1);