clean up benchmark logic

This commit is contained in:
Christian Grothoff 2020-01-19 17:03:30 +01:00
parent 9f522baadc
commit ce5adddaf3
No known key found for this signature in database
GPG Key ID: 939E6BE1E29FC3CC

View File

@ -105,6 +105,11 @@ static struct GNUNET_TIME_Absolute start_time;
*/ */
static struct GNUNET_TIME_Relative duration; static struct GNUNET_TIME_Relative duration;
/**
* Array of all the commands the benchmark is running.
*/
static struct TALER_TESTING_Command *all_commands;
/** /**
* Exit code. * Exit code.
*/ */
@ -231,7 +236,10 @@ eval_probability (float probability)
/** /**
* Actual commands collection. * Actual commands construction and execution.
*
* @param cls unused
* @param is interpreter to run commands with
*/ */
static void static void
run (void *cls, run (void *cls,
@ -240,23 +248,21 @@ run (void *cls,
struct TALER_Amount total_reserve_amount; struct TALER_Amount total_reserve_amount;
struct TALER_Amount withdraw_fee; struct TALER_Amount withdraw_fee;
char *withdraw_fee_str; char *withdraw_fee_str;
struct TALER_TESTING_Command all_commands char *amount_5;
[howmany_reserves * (1 /* Withdraw block */ char *amount_4;
+ howmany_coins) /* All units */ char *amount_1;
+ 1 /* End CMD */];
char *AMOUNT_5;
char *AMOUNT_4;
char *AMOUNT_1;
(void) cls; (void) cls;
GNUNET_asprintf (&AMOUNT_5, "%s:5", currency); all_commands = GNUNET_new_array (howmany_reserves * (1 /* Withdraw block */
GNUNET_asprintf (&AMOUNT_4, "%s:4", currency); + howmany_coins) /* All units */
GNUNET_asprintf (&AMOUNT_1, "%s:1", currency); + 1 /* End CMD */,
struct TALER_TESTING_Command);
GNUNET_asprintf (&amount_5, "%s:5", currency);
GNUNET_asprintf (&amount_4, "%s:4", currency);
GNUNET_asprintf (&amount_1, "%s:1", currency);
GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (currency, GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (currency,
&total_reserve_amount)); &total_reserve_amount));
total_reserve_amount.value = 5 * howmany_coins; total_reserve_amount.value = 5 * howmany_coins;
GNUNET_asprintf (&withdraw_fee_str, GNUNET_asprintf (&withdraw_fee_str,
"%s:0.1", "%s:0.1",
currency); currency);
@ -277,9 +283,9 @@ run (void *cls,
j); j);
{ {
struct TALER_TESTING_Command make_reserve[] = { struct TALER_TESTING_Command make_reserve[] = {
CMD_TRANSFER_TO_EXCHANGE CMD_TRANSFER_TO_EXCHANGE (create_reserve_label,
(create_reserve_label, TALER_amount_to_string
TALER_amount_to_string (&total_reserve_amount)), (&total_reserve_amount)),
TALER_TESTING_cmd_end () TALER_TESTING_cmd_end ()
}; };
char *batch_label; char *batch_label;
@ -306,23 +312,21 @@ run (void *cls,
"{\"nonce\": %llu}", "{\"nonce\": %llu}",
i + (howmany_coins * j)); i + (howmany_coins * j));
unit[0] = unit[0] =
TALER_TESTING_cmd_withdraw_with_retry TALER_TESTING_cmd_withdraw_with_retry (TALER_TESTING_cmd_withdraw_amount
(TALER_TESTING_cmd_withdraw_amount (withdraw_label,
(withdraw_label, create_reserve_label,
create_reserve_label, amount_5,
AMOUNT_5, MHD_HTTP_OK));
MHD_HTTP_OK));
unit[1] = unit[1] =
TALER_TESTING_cmd_deposit_with_retry TALER_TESTING_cmd_deposit_with_retry
(TALER_TESTING_cmd_deposit (TALER_TESTING_cmd_deposit ("deposit",
("deposit", withdraw_label,
withdraw_label, 0, /* Index of the one withdrawn coin in the traits. */
0, /* Index of the one withdrawn coin in the traits. */ user_payto_url,
user_payto_url, order_enc,
order_enc, GNUNET_TIME_UNIT_ZERO,
GNUNET_TIME_UNIT_ZERO, amount_1,
AMOUNT_1, MHD_HTTP_OK));
MHD_HTTP_OK));
if (eval_probability (refresh_rate / 100.0)) if (eval_probability (refresh_rate / 100.0))
{ {
@ -338,8 +342,8 @@ run (void *cls,
i, i,
j); j);
unit[2] = unit[2] =
TALER_TESTING_cmd_refresh_melt_with_retry TALER_TESTING_cmd_refresh_melt_with_retry (
(TALER_TESTING_cmd_refresh_melt TALER_TESTING_cmd_refresh_melt
(melt_label, (melt_label,
withdraw_label, withdraw_label,
MHD_HTTP_OK, MHD_HTTP_OK,