diff options
Diffstat (limited to 'nacl/crypto_scalarmult/measure.c')
-rw-r--r-- | nacl/crypto_scalarmult/measure.c | 61 |
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 | |||
6 | extern void printentry(long long,const char *,long long *,long long); | ||
7 | extern unsigned char *alignedcalloc(unsigned long long); | ||
8 | extern const char *primitiveimplementation; | ||
9 | extern const char *implementationversion; | ||
10 | extern const char *sizenames[]; | ||
11 | extern const long long sizes[]; | ||
12 | extern void allocate(void); | ||
13 | extern void measure(void); | ||
14 | |||
15 | const char *primitiveimplementation = crypto_scalarmult_IMPLEMENTATION; | ||
16 | const char *implementationversion = crypto_scalarmult_VERSION; | ||
17 | const char *sizenames[] = { "outputbytes", "scalarbytes", 0 }; | ||
18 | const long long sizes[] = { crypto_scalarmult_BYTES, crypto_scalarmult_SCALARBYTES }; | ||
19 | |||
20 | static unsigned char *m; | ||
21 | static unsigned char *n; | ||
22 | static unsigned char *p; | ||
23 | static unsigned char *q; | ||
24 | |||
25 | void preallocate(void) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | void 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 | ||
38 | static long long cycles[TIMINGS + 1]; | ||
39 | |||
40 | void 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 | } | ||