summaryrefslogtreecommitdiff
path: root/src/util/perf_crypto_hash.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/perf_crypto_hash.c')
-rw-r--r--src/util/perf_crypto_hash.c83
1 files changed, 43 insertions, 40 deletions
diff --git a/src/util/perf_crypto_hash.c b/src/util/perf_crypto_hash.c
index cdcff2824..95eca8e7a 100644
--- a/src/util/perf_crypto_hash.c
+++ b/src/util/perf_crypto_hash.c
@@ -30,80 +30,83 @@
30 30
31 31
32static void 32static void
33perfHash() 33perfHash ()
34{ 34{
35 struct GNUNET_HashCode hc; 35 struct GNUNET_HashCode hc;
36 unsigned int i; 36 unsigned int i;
37 char buf[64 * 1024]; 37 char buf[64 * 1024];
38 38
39 memset(buf, 1, sizeof(buf)); 39 memset (buf, 1, sizeof(buf));
40 for (i = 0; i < 1024; i++) 40 for (i = 0; i < 1024; i++)
41 GNUNET_CRYPTO_hash(buf, sizeof(buf), &hc); 41 GNUNET_CRYPTO_hash (buf, sizeof(buf), &hc);
42} 42}
43 43
44 44
45static void 45static void
46perfHashSmall() 46perfHashSmall ()
47{ 47{
48 struct GNUNET_HashCode hc; 48 struct GNUNET_HashCode hc;
49 unsigned int i; 49 unsigned int i;
50 char buf[64]; 50 char buf[64];
51 51
52 memset(buf, 1, sizeof(buf)); 52 memset (buf, 1, sizeof(buf));
53 for (i = 0; i < 1024; i++) 53 for (i = 0; i < 1024; i++)
54 GNUNET_CRYPTO_hash(buf, sizeof(buf), &hc); 54 GNUNET_CRYPTO_hash (buf, sizeof(buf), &hc);
55} 55}
56 56
57 57
58static void 58static void
59perfHKDF() 59perfHKDF ()
60{ 60{
61 unsigned int i; 61 unsigned int i;
62 char res[128]; 62 char res[128];
63 char buf[128]; 63 char buf[128];
64 char skm[64]; 64 char skm[64];
65 65
66 memset(buf, 1, sizeof(buf)); 66 memset (buf, 1, sizeof(buf));
67 memset(skm, 2, sizeof(skm)); 67 memset (skm, 2, sizeof(skm));
68 for (i = 0; i < 1024; i++) 68 for (i = 0; i < 1024; i++)
69 GNUNET_CRYPTO_hkdf(res, sizeof(res), 69 GNUNET_CRYPTO_hkdf (res, sizeof(res),
70 GCRY_MD_SHA512, GCRY_MD_SHA256, 70 GCRY_MD_SHA512, GCRY_MD_SHA256,
71 buf, sizeof(buf), 71 buf, sizeof(buf),
72 skm, sizeof(skm), 72 skm, sizeof(skm),
73 "test", (size_t)4, 73 "test", (size_t) 4,
74 NULL, 0); 74 NULL, 0);
75} 75}
76 76
77 77
78int 78int
79main(int argc, char *argv[]) 79main (int argc, char *argv[])
80{ 80{
81 struct GNUNET_TIME_Absolute start; 81 struct GNUNET_TIME_Absolute start;
82 82
83 start = GNUNET_TIME_absolute_get(); 83 start = GNUNET_TIME_absolute_get ();
84 perfHashSmall(); 84 perfHashSmall ();
85 printf("1024x 64-byte Hash perf took %s\n", 85 printf ("1024x 64-byte Hash perf took %s\n",
86 GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_duration(start), 86 GNUNET_STRINGS_relative_time_to_string (
87 GNUNET_YES)); 87 GNUNET_TIME_absolute_get_duration (start),
88 88 GNUNET_YES));
89 start = GNUNET_TIME_absolute_get(); 89
90 perfHash(); 90 start = GNUNET_TIME_absolute_get ();
91 printf("1024x 64k Hash perf took %s\n", 91 perfHash ();
92 GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_duration(start), 92 printf ("1024x 64k Hash perf took %s\n",
93 GNUNET_YES)); 93 GNUNET_STRINGS_relative_time_to_string (
94 GAUGER("UTIL", "Cryptographic hashing", 94 GNUNET_TIME_absolute_get_duration (start),
95 64 * 1024 / (1 + 95 GNUNET_YES));
96 GNUNET_TIME_absolute_get_duration 96 GAUGER ("UTIL", "Cryptographic hashing",
97 (start).rel_value_us / 1000LL), "kb/ms"); 97 64 * 1024 / (1
98 start = GNUNET_TIME_absolute_get(); 98 + GNUNET_TIME_absolute_get_duration
99 perfHKDF(); 99 (start).rel_value_us / 1000LL), "kb/ms");
100 printf("HKDF perf took %s\n", 100 start = GNUNET_TIME_absolute_get ();
101 GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_duration(start), 101 perfHKDF ();
102 GNUNET_YES)); 102 printf ("HKDF perf took %s\n",
103 GAUGER("UTIL", "Cryptographic HKDF", 103 GNUNET_STRINGS_relative_time_to_string (
104 64 * 1024 / (1 + 104 GNUNET_TIME_absolute_get_duration (start),
105 GNUNET_TIME_absolute_get_duration 105 GNUNET_YES));
106 (start).rel_value_us / 1000LL), "kb/ms"); 106 GAUGER ("UTIL", "Cryptographic HKDF",
107 64 * 1024 / (1
108 + GNUNET_TIME_absolute_get_duration
109 (start).rel_value_us / 1000LL), "kb/ms");
107 return 0; 110 return 0;
108} 111}
109 112