2 This file is part of GNUnet.
3 Copyright (C) 2002, 2003, 2004, 2006 GNUnet e.V.
5 GNUnet is free software: you can redistribute it and/or modify it
6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Affero General Public License for more details.
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/>.
20 * @author Christian Grothoff
21 * @file util/perf_crypto_hash.c
22 * @brief measure performance of hash function
25 #include "gnunet_util_lib.h"
33 struct GNUNET_HashCode hc;
37 memset (buf, 1, sizeof (buf));
38 for (i = 0; i < 1024; i++)
39 GNUNET_CRYPTO_hash (buf, sizeof (buf), &hc);
46 struct GNUNET_HashCode hc;
50 memset (buf, 1, sizeof (buf));
51 for (i = 0; i < 1024; i++)
52 GNUNET_CRYPTO_hash (buf, sizeof (buf), &hc);
64 memset (buf, 1, sizeof (buf));
65 memset (skm, 2, sizeof (skm));
66 for (i = 0; i < 1024; i++)
67 GNUNET_CRYPTO_hkdf (res, sizeof (res),
68 GCRY_MD_SHA512, GCRY_MD_SHA256,
77 main (int argc, char *argv[])
79 struct GNUNET_TIME_Absolute start;
81 start = GNUNET_TIME_absolute_get ();
83 printf ("1024x 64-byte Hash perf took %s\n",
84 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start),
87 start = GNUNET_TIME_absolute_get ();
89 printf ("1024x 64k Hash perf took %s\n",
90 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start),
92 GAUGER ("UTIL", "Cryptographic hashing",
94 GNUNET_TIME_absolute_get_duration
95 (start).rel_value_us / 1000LL), "kb/ms");
96 start = GNUNET_TIME_absolute_get ();
98 printf ("HKDF perf took %s\n",
99 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start),
101 GAUGER ("UTIL", "Cryptographic HKDF",
103 GNUNET_TIME_absolute_get_duration
104 (start).rel_value_us / 1000LL), "kb/ms");
108 /* end of perf_crypto_hash.c */