diff options
author | irungentoo <irungentoo@gmail.com> | 2013-07-13 10:09:38 -0400 |
---|---|---|
committer | irungentoo <irungentoo@gmail.com> | 2013-07-13 10:09:38 -0400 |
commit | d4fe483efd3e0062f12430efe9deb66d43d914d7 (patch) | |
tree | e6aa9ac716ae82cdb15c6e6cb5d9d1d9d29f053b /nacl/crypto_hash/measure.c | |
parent | 835ef0320d47372eac14bef31c979b8217d04498 (diff) |
NaCl moved to other repo.
Diffstat (limited to 'nacl/crypto_hash/measure.c')
-rw-r--r-- | nacl/crypto_hash/measure.c | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/nacl/crypto_hash/measure.c b/nacl/crypto_hash/measure.c deleted file mode 100644 index cec0404d..00000000 --- a/nacl/crypto_hash/measure.c +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include "randombytes.h" | ||
3 | #include "cpucycles.h" | ||
4 | #include "crypto_hash.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_hash_IMPLEMENTATION; | ||
16 | const char *implementationversion = crypto_hash_VERSION; | ||
17 | const char *sizenames[] = { "outputbytes", 0 }; | ||
18 | const long long sizes[] = { crypto_hash_BYTES }; | ||
19 | |||
20 | #define MAXTEST_BYTES 4096 | ||
21 | #ifdef SUPERCOP | ||
22 | #define MGAP 8192 | ||
23 | #else | ||
24 | #define MGAP 8 | ||
25 | #endif | ||
26 | |||
27 | static unsigned char *h; | ||
28 | static unsigned char *m; | ||
29 | |||
30 | void preallocate(void) | ||
31 | { | ||
32 | } | ||
33 | |||
34 | void allocate(void) | ||
35 | { | ||
36 | h = alignedcalloc(crypto_hash_BYTES); | ||
37 | m = alignedcalloc(MAXTEST_BYTES); | ||
38 | } | ||
39 | |||
40 | #define TIMINGS 15 | ||
41 | static long long cycles[TIMINGS + 1]; | ||
42 | |||
43 | static void printcycles(long long mlen) | ||
44 | { | ||
45 | int i; | ||
46 | for (i = 0;i < TIMINGS;++i) cycles[i] = cycles[i + 1] - cycles[i]; | ||
47 | printentry(mlen,"cycles",cycles,TIMINGS); | ||
48 | } | ||
49 | |||
50 | void measure(void) | ||
51 | { | ||
52 | int i; | ||
53 | int loop; | ||
54 | int mlen; | ||
55 | |||
56 | for (loop = 0;loop < LOOPS;++loop) { | ||
57 | for (mlen = 0;mlen <= MAXTEST_BYTES;mlen += 1 + mlen / MGAP) { | ||
58 | randombytes(m,mlen); | ||
59 | for (i = 0;i <= TIMINGS;++i) { | ||
60 | cycles[i] = cpucycles(); | ||
61 | crypto_hash(h,m,mlen); | ||
62 | } | ||
63 | printcycles(mlen); | ||
64 | } | ||
65 | } | ||
66 | } | ||