From 207c97590234a9ec0c42af960344444f32ee8d27 Mon Sep 17 00:00:00 2001 From: Marcello Stanisci Date: Wed, 25 Jul 2018 11:45:14 +0200 Subject: Benchmark. Measuring time and print outcome. --- src/benchmark/taler-exchange-benchmark-new.c | 36 +++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'src/benchmark') diff --git a/src/benchmark/taler-exchange-benchmark-new.c b/src/benchmark/taler-exchange-benchmark-new.c index df3770cac..9cdd26dbf 100644 --- a/src/benchmark/taler-exchange-benchmark-new.c +++ b/src/benchmark/taler-exchange-benchmark-new.c @@ -48,15 +48,10 @@ enum BenchmarkError { }; /** - * Probability a coin can be refreshed. - * This probability multiplied by the number of coins - * generated during the average refresh must be smaller - * than one. The variance must be covered by the - * #INVALID_COIN_SLACK. + * Probability that a spent coin will be refreshed. */ #define REFRESH_PROBABILITY 0.1 - /** * The whole benchmark is a repetition of a "unit". Each * unit is a array containing a withdraw+deposit operation, @@ -82,6 +77,18 @@ enum BenchmarkError { bank_url, USER_ACCOUNT_NO, EXCHANGE_ACCOUNT_NO, \ USER_LOGIN_NAME, USER_LOGIN_PASS, EXCHANGE_URL) + +/** + * Time snapshot taken right before executing the CMDs. + */ +static struct GNUNET_TIME_Absolute start_time; + +/** + * Benchmark duration time taken right after the CMD interpreter + * returns. + */ +static struct GNUNET_TIME_Relative duration; + /** * Exit code. */ @@ -92,6 +99,11 @@ static unsigned int result; */ static struct GNUNET_OS_Process *bankd; +/** + * How many refreshes got executed. + */ +static unsigned int howmany_refreshes; + /** * How many coins we want to create. */ @@ -258,6 +270,7 @@ run (void *cls, char *melt_label; char *reveal_label; + howmany_refreshes++; GNUNET_asprintf (&melt_label, "refresh-melt-%u", i); @@ -293,6 +306,8 @@ run (void *cls, unit); } all_commands[1 + howmany_coins] = TALER_TESTING_cmd_end (); + + start_time = GNUNET_TIME_absolute_get (); TALER_TESTING_run (is, all_commands); result = 1; @@ -424,7 +439,16 @@ main (int argc, NULL, cfg_filename); + duration = GNUNET_TIME_absolute_get_duration (start_time); terminate_process (bankd); + TALER_LOG_INFO ("Executed W=%u, D=%u, R=%u, operations in %s\n", + howmany_coins, + howmany_coins, + howmany_refreshes, + GNUNET_STRINGS_relative_time_to_string + (duration, + GNUNET_YES)); + return (GNUNET_OK == result) ? 0 : result; } -- cgit v1.2.3