From b51d78907d2e16e38c8d95d69827d99bc0a9612d Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sat, 18 Aug 2018 00:47:04 +0200 Subject: basic benchmarking --- configure.ac | 11 +++++++++++ po/POTFILES.in | 1 + src/util/Makefile.am | 8 +++++++- src/util/crypto_ecc.c | 7 +++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index d37c2cb5f..10991e574 100644 --- a/configure.ac +++ b/configure.ac @@ -1388,6 +1388,17 @@ fi AC_SUBST(MONKEYPREFIX) +AC_MSG_CHECKING([whether to compile in benchmarks (currently for http and crypto)]) +AC_ARG_ENABLE([benchmark], + [AS_HELP_STRING([--enable-benchmark], [enable benchmarking])], + [enable_benchmark=${enableval}], + [enable_benchmark=no]) +AC_MSG_RESULT($enable_benchmark) +AS_IF([test "x$enable_benchmark" = "xyes"], + [AC_DEFINE_UNQUOTED(ENABLE_BENCHMARK,1,[Benchmarks are enabled])]) +AM_CONDITIONAL([ENABLE_BENCHMARK], [test "x$enable_benchmark" = "xyes"]) + + # should expensive tests be run? AC_MSG_CHECKING(whether to run expensive tests) AC_ARG_ENABLE([expensivetests], diff --git a/po/POTFILES.in b/po/POTFILES.in index 0dd50e62b..45471731c 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -445,6 +445,7 @@ src/transport/transport-testing-loggers.c src/transport/transport-testing-main.c src/transport/transport-testing-send.c src/util/bandwidth.c +src/util/benchmark.c src/util/bio.c src/util/client.c src/util/common_allocation.c diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 4ae073c2c..b0f45b1da 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -40,6 +40,11 @@ if USE_COVERAGE XLIB = -lgcov endif +if ENABLE_BENCHMARK + BENCHMARK = benchmark.c + PTHREAD = -lpthread +endif + w32cat_SOURCES = w32cat.c gnunet_helper_w32_console_SOURCES = \ @@ -60,6 +65,7 @@ test_common_logging_dummy_LDADD = \ libgnunetutil_la_SOURCES = \ bandwidth.c \ + $(BENCHMARK) \ bio.c \ client.c \ common_allocation.c \ @@ -121,7 +127,7 @@ libgnunetutil_la_LIBADD = \ $(LIBGCRYPT_LIBS) \ $(LTLIBICONV) \ $(LTLIBINTL) \ - -lltdl -lidn $(Z_LIBS) -lunistring $(XLIB) + -lltdl -lidn $(Z_LIBS) -lunistring $(XLIB) $(PTHREAD) libgnunetutil_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) \ diff --git a/src/util/crypto_ecc.c b/src/util/crypto_ecc.c index 07782b181..ed20fa2c8 100644 --- a/src/util/crypto_ecc.c +++ b/src/util/crypto_ecc.c @@ -25,6 +25,7 @@ #include #include "gnunet_crypto_lib.h" #include "gnunet_strings_lib.h" +#include "benchmark.h" #define EXTRA_CHECKS 0 @@ -873,6 +874,12 @@ GNUNET_CRYPTO_eddsa_sign (const struct GNUNET_CRYPTO_EddsaPrivateKey *priv, int rc; gcry_mpi_t rs[2]; +#if ENABLE_BENCHMARK + struct BenchmarkData *bd = get_benchmark_data (); + bd->eddsa_sign_count++; + printf("crypto eddsa sign\n"); +#endif + priv_sexp = decode_private_eddsa_key (priv); data = data_to_eddsa_value (purpose); if (0 != (rc = gcry_pk_sign (&sig_sexp, data, priv_sexp))) -- cgit v1.2.3