diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-08-18 15:10:39 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-08-18 15:10:39 +0200 |
commit | af99085b7163fdded4dfad94fd2a98231bc12209 (patch) | |
tree | c055728c186a49be04c4381bf10f890eaba482c6 /src/util/crypto_hash.c | |
parent | ec8162bdf0db6282fbf507e6da72b056119c7805 (diff) | |
download | gnunet-af99085b7163fdded4dfad94fd2a98231bc12209.tar.gz gnunet-af99085b7163fdded4dfad94fd2a98231bc12209.zip |
benchmark collection awk scripts
Diffstat (limited to 'src/util/crypto_hash.c')
-rw-r--r-- | src/util/crypto_hash.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/util/crypto_hash.c b/src/util/crypto_hash.c index fe1f58df7..cd36fbbd7 100644 --- a/src/util/crypto_hash.c +++ b/src/util/crypto_hash.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include "platform.h" | 24 | #include "platform.h" |
25 | #include "gnunet_crypto_lib.h" | 25 | #include "gnunet_crypto_lib.h" |
26 | #include "gnunet_strings_lib.h" | 26 | #include "gnunet_strings_lib.h" |
27 | #include "benchmark.h" | ||
27 | #include <gcrypt.h> | 28 | #include <gcrypt.h> |
28 | 29 | ||
29 | #define LOG(kind,...) GNUNET_log_from (kind, "util-crypto-hash", __VA_ARGS__) | 30 | #define LOG(kind,...) GNUNET_log_from (kind, "util-crypto-hash", __VA_ARGS__) |
@@ -42,7 +43,9 @@ GNUNET_CRYPTO_hash (const void *block, | |||
42 | size_t size, | 43 | size_t size, |
43 | struct GNUNET_HashCode *ret) | 44 | struct GNUNET_HashCode *ret) |
44 | { | 45 | { |
46 | BENCHMARK_START (hash); | ||
45 | gcry_md_hash_buffer (GCRY_MD_SHA512, ret, block, size); | 47 | gcry_md_hash_buffer (GCRY_MD_SHA512, ret, block, size); |
48 | BENCHMARK_END (hash); | ||
46 | } | 49 | } |
47 | 50 | ||
48 | 51 | ||
@@ -442,11 +445,16 @@ GNUNET_CRYPTO_hash_context_start () | |||
442 | { | 445 | { |
443 | struct GNUNET_HashContext *hc; | 446 | struct GNUNET_HashContext *hc; |
444 | 447 | ||
448 | BENCHMARK_START (hash_context_start); | ||
449 | |||
445 | hc = GNUNET_new (struct GNUNET_HashContext); | 450 | hc = GNUNET_new (struct GNUNET_HashContext); |
446 | GNUNET_assert (0 == | 451 | GNUNET_assert (0 == |
447 | gcry_md_open (&hc->hd, | 452 | gcry_md_open (&hc->hd, |
448 | GCRY_MD_SHA512, | 453 | GCRY_MD_SHA512, |
449 | 0)); | 454 | 0)); |
455 | |||
456 | BENCHMARK_END (hash_context_start); | ||
457 | |||
450 | return hc; | 458 | return hc; |
451 | } | 459 | } |
452 | 460 | ||
@@ -463,7 +471,9 @@ GNUNET_CRYPTO_hash_context_read (struct GNUNET_HashContext *hc, | |||
463 | const void *buf, | 471 | const void *buf, |
464 | size_t size) | 472 | size_t size) |
465 | { | 473 | { |
474 | BENCHMARK_START (hash_context_read); | ||
466 | gcry_md_write (hc->hd, buf, size); | 475 | gcry_md_write (hc->hd, buf, size); |
476 | BENCHMARK_END (hash_context_read); | ||
467 | } | 477 | } |
468 | 478 | ||
469 | 479 | ||
@@ -479,12 +489,15 @@ GNUNET_CRYPTO_hash_context_finish (struct GNUNET_HashContext *hc, | |||
479 | { | 489 | { |
480 | const void *res = gcry_md_read (hc->hd, 0); | 490 | const void *res = gcry_md_read (hc->hd, 0); |
481 | 491 | ||
492 | BENCHMARK_START (hash_context_finish); | ||
493 | |||
482 | GNUNET_assert (NULL != res); | 494 | GNUNET_assert (NULL != res); |
483 | if (NULL != r_hash) | 495 | if (NULL != r_hash) |
484 | GNUNET_memcpy (r_hash, | 496 | GNUNET_memcpy (r_hash, |
485 | res, | 497 | res, |
486 | sizeof (struct GNUNET_HashCode)); | 498 | sizeof (struct GNUNET_HashCode)); |
487 | GNUNET_CRYPTO_hash_context_abort (hc); | 499 | GNUNET_CRYPTO_hash_context_abort (hc); |
500 | BENCHMARK_END (hash_context_finish); | ||
488 | } | 501 | } |
489 | 502 | ||
490 | 503 | ||