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.
17 * @author Christian Grothoff
18 * @file util/perf_crypto_hash.c
19 * @brief measure performance of hash function
22 #include "gnunet_util_lib.h"
30 struct GNUNET_HashCode hc;
34 memset (buf, 1, sizeof (buf));
35 for (i = 0; i < 1024; i++)
36 GNUNET_CRYPTO_hash (buf, sizeof (buf), &hc);
43 struct GNUNET_HashCode hc;
47 memset (buf, 1, sizeof (buf));
48 for (i = 0; i < 1024; i++)
49 GNUNET_CRYPTO_hash (buf, sizeof (buf), &hc);
61 memset (buf, 1, sizeof (buf));
62 memset (skm, 2, sizeof (skm));
63 for (i = 0; i < 1024; i++)
64 GNUNET_CRYPTO_hkdf (res, sizeof (res),
65 GCRY_MD_SHA512, GCRY_MD_SHA256,
74 main (int argc, char *argv[])
76 struct GNUNET_TIME_Absolute start;
78 start = GNUNET_TIME_absolute_get ();
80 printf ("1024x 64-byte Hash perf took %s\n",
81 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start),
84 start = GNUNET_TIME_absolute_get ();
86 printf ("1024x 64k Hash perf took %s\n",
87 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start),
89 GAUGER ("UTIL", "Cryptographic hashing",
91 GNUNET_TIME_absolute_get_duration
92 (start).rel_value_us / 1000LL), "kb/ms");
93 start = GNUNET_TIME_absolute_get ();
95 printf ("HKDF perf took %s\n",
96 GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start),
98 GAUGER ("UTIL", "Cryptographic HKDF",
100 GNUNET_TIME_absolute_get_duration
101 (start).rel_value_us / 1000LL), "kb/ms");
105 /* end of perf_crypto_hash.c */