diff options
Diffstat (limited to 'src/util/perf_crypto_hash.c')
-rw-r--r-- | src/util/perf_crypto_hash.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/src/util/perf_crypto_hash.c b/src/util/perf_crypto_hash.c index c74f425ce..cdcff2824 100644 --- a/src/util/perf_crypto_hash.c +++ b/src/util/perf_crypto_hash.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @author Christian Grothoff | 22 | * @author Christian Grothoff |
@@ -30,80 +30,80 @@ | |||
30 | 30 | ||
31 | 31 | ||
32 | static void | 32 | static void |
33 | perfHash () | 33 | perfHash() |
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 | ||
45 | static void | 45 | static void |
46 | perfHashSmall () | 46 | perfHashSmall() |
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 | ||
58 | static void | 58 | static void |
59 | perfHKDF () | 59 | perfHKDF() |
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 | ||
78 | int | 78 | int |
79 | main (int argc, char *argv[]) | 79 | main(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(GNUNET_TIME_absolute_get_duration(start), |
87 | GNUNET_YES)); | 87 | GNUNET_YES)); |
88 | 88 | ||
89 | start = GNUNET_TIME_absolute_get (); | 89 | start = GNUNET_TIME_absolute_get(); |
90 | perfHash (); | 90 | perfHash(); |
91 | printf ("1024x 64k Hash perf took %s\n", | 91 | printf("1024x 64k Hash perf took %s\n", |
92 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), | 92 | GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_duration(start), |
93 | GNUNET_YES)); | 93 | GNUNET_YES)); |
94 | GAUGER ("UTIL", "Cryptographic hashing", | 94 | GAUGER("UTIL", "Cryptographic hashing", |
95 | 64 * 1024 / (1 + | 95 | 64 * 1024 / (1 + |
96 | GNUNET_TIME_absolute_get_duration | 96 | GNUNET_TIME_absolute_get_duration |
97 | (start).rel_value_us / 1000LL), "kb/ms"); | 97 | (start).rel_value_us / 1000LL), "kb/ms"); |
98 | start = GNUNET_TIME_absolute_get (); | 98 | start = GNUNET_TIME_absolute_get(); |
99 | perfHKDF (); | 99 | perfHKDF(); |
100 | printf ("HKDF perf took %s\n", | 100 | printf("HKDF perf took %s\n", |
101 | GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), | 101 | GNUNET_STRINGS_relative_time_to_string(GNUNET_TIME_absolute_get_duration(start), |
102 | GNUNET_YES)); | 102 | GNUNET_YES)); |
103 | GAUGER ("UTIL", "Cryptographic HKDF", | 103 | GAUGER("UTIL", "Cryptographic HKDF", |
104 | 64 * 1024 / (1 + | 104 | 64 * 1024 / (1 + |
105 | GNUNET_TIME_absolute_get_duration | 105 | GNUNET_TIME_absolute_get_duration |
106 | (start).rel_value_us / 1000LL), "kb/ms"); | 106 | (start).rel_value_us / 1000LL), "kb/ms"); |
107 | return 0; | 107 | return 0; |
108 | } | 108 | } |
109 | 109 | ||