summaryrefslogtreecommitdiff
path: root/nacl/crypto_scalarmult/measure.c
diff options
context:
space:
mode:
Diffstat (limited to 'nacl/crypto_scalarmult/measure.c')
-rw-r--r--nacl/crypto_scalarmult/measure.c61
1 files changed, 0 insertions, 61 deletions
diff --git a/nacl/crypto_scalarmult/measure.c b/nacl/crypto_scalarmult/measure.c
deleted file mode 100644
index 0c7265d5..00000000
--- a/nacl/crypto_scalarmult/measure.c
+++ /dev/null
@@ -1,61 +0,0 @@
1#include <stdlib.h>
2#include "randombytes.h"
3#include "cpucycles.h"
4#include "crypto_scalarmult.h"
5
6extern void printentry(long long,const char *,long long *,long long);
7extern unsigned char *alignedcalloc(unsigned long long);
8extern const char *primitiveimplementation;
9extern const char *implementationversion;
10extern const char *sizenames[];
11extern const long long sizes[];
12extern void allocate(void);
13extern void measure(void);
14
15const char *primitiveimplementation = crypto_scalarmult_IMPLEMENTATION;
16const char *implementationversion = crypto_scalarmult_VERSION;
17const char *sizenames[] = { "outputbytes", "scalarbytes", 0 };
18const long long sizes[] = { crypto_scalarmult_BYTES, crypto_scalarmult_SCALARBYTES };
19
20static unsigned char *m;
21static unsigned char *n;
22static unsigned char *p;
23static unsigned char *q;
24
25void preallocate(void)
26{
27}
28
29void allocate(void)
30{
31 m = alignedcalloc(crypto_scalarmult_SCALARBYTES);
32 n = alignedcalloc(crypto_scalarmult_SCALARBYTES);
33 p = alignedcalloc(crypto_scalarmult_BYTES);
34 q = alignedcalloc(crypto_scalarmult_BYTES);
35}
36
37#define TIMINGS 63
38static long long cycles[TIMINGS + 1];
39
40void measure(void)
41{
42 int i;
43 int loop;
44
45 for (loop = 0;loop < LOOPS;++loop) {
46 randombytes(m,crypto_scalarmult_SCALARBYTES);
47 randombytes(n,crypto_scalarmult_SCALARBYTES);
48 for (i = 0;i <= TIMINGS;++i) {
49 cycles[i] = cpucycles();
50 crypto_scalarmult_base(p,m);
51 }
52 for (i = 0;i < TIMINGS;++i) cycles[i] = cycles[i + 1] - cycles[i];
53 printentry(-1,"base_cycles",cycles,TIMINGS);
54 for (i = 0;i <= TIMINGS;++i) {
55 cycles[i] = cpucycles();
56 crypto_scalarmult(q,n,p);
57 }
58 for (i = 0;i < TIMINGS;++i) cycles[i] = cycles[i + 1] - cycles[i];
59 printentry(-1,"cycles",cycles,TIMINGS);
60 }
61}