From eb559970846f0fa27f1f25c482cd07210a56f4b1 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Sun, 25 Aug 2019 16:18:24 +0200 Subject: re-format code --- src/benchmark/taler-exchange-benchmark.c | 194 ++++++++++++++++--------------- 1 file changed, 103 insertions(+), 91 deletions(-) (limited to 'src/benchmark/taler-exchange-benchmark.c') diff --git a/src/benchmark/taler-exchange-benchmark.c b/src/benchmark/taler-exchange-benchmark.c index 094f23c74..d106eb557 100644 --- a/src/benchmark/taler-exchange-benchmark.c +++ b/src/benchmark/taler-exchange-benchmark.c @@ -41,7 +41,8 @@ #include "taler_error_codes.h" /* Error codes. */ -enum BenchmarkError { +enum BenchmarkError +{ MISSING_BANK_URL, FAILED_TO_LAUNCH_BANK, BAD_CLI_ARG, @@ -67,20 +68,23 @@ enum BenchmarkError { #define FIRST_INSTRUCTION -1 #define CMD_TRANSFER_TO_EXCHANGE(label, amount) \ - TALER_TESTING_cmd_fakebank_transfer_retry \ + TALER_TESTING_cmd_fakebank_transfer_retry \ (TALER_TESTING_cmd_fakebank_transfer (label, amount, \ - exchange_bank_account.details.x_taler_bank.bank_base_url, \ - USER_ACCOUNT_NUMBER, \ - exchange_bank_account.details.x_taler_bank.no, \ - "dummy_user", \ - "dummy_password", \ - "http://example.com/")) + exchange_bank_account.details. \ + x_taler_bank.bank_base_url, \ + USER_ACCOUNT_NUMBER, \ + exchange_bank_account.details. \ + x_taler_bank.no, \ + "dummy_user", \ + "dummy_password", \ + "http://example.com/")) /** * What mode should the benchmark run in? */ -enum BenchmarkMode { +enum BenchmarkMode +{ /** * Run as client (with fakebank), also starts a remote exchange. */ @@ -222,7 +226,7 @@ eval_probability (float probability) float random_01; random = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK, - UINT64_MAX); + UINT64_MAX); random_01 = (double) random / UINT64_MAX; return (random_01 <= probability) ? GNUNET_OK : GNUNET_NO; } @@ -239,9 +243,9 @@ run (void *cls, struct TALER_Amount withdraw_fee; char *withdraw_fee_str; struct TALER_TESTING_Command all_commands - [howmany_reserves * (1 + /* Withdraw block */ - howmany_coins) + /* All units */ - 1 /* End CMD */]; + [howmany_reserves * (1 /* Withdraw block */ + + howmany_coins) /* All units */ + + 1 /* End CMD */]; char *AMOUNT_5; char *AMOUNT_4; char *AMOUNT_1; @@ -250,7 +254,8 @@ run (void *cls, GNUNET_asprintf (&AMOUNT_4, "%s:4", currency); GNUNET_asprintf (&AMOUNT_1, "%s:1", currency); - GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (currency, &total_reserve_amount)); + GNUNET_assert (GNUNET_OK == TALER_amount_get_zero (currency, + &total_reserve_amount)); total_reserve_amount.value = 5 * howmany_coins; GNUNET_asprintf (&withdraw_fee_str, @@ -274,8 +279,8 @@ run (void *cls, { struct TALER_TESTING_Command make_reserve[] = { CMD_TRANSFER_TO_EXCHANGE - (create_reserve_label, - TALER_amount_to_string (&total_reserve_amount)), + (create_reserve_label, + TALER_amount_to_string (&total_reserve_amount)), TALER_TESTING_cmd_end () }; char *batch_label; @@ -303,24 +308,24 @@ run (void *cls, i + (howmany_coins * j)); unit[0] = TALER_TESTING_cmd_withdraw_with_retry - (TALER_TESTING_cmd_withdraw_amount - (withdraw_label, - create_reserve_label, - AMOUNT_5, - MHD_HTTP_OK)); + (TALER_TESTING_cmd_withdraw_amount + (withdraw_label, + create_reserve_label, + AMOUNT_5, + MHD_HTTP_OK)); unit[1] = TALER_TESTING_cmd_deposit_with_retry - (TALER_TESTING_cmd_deposit - ("deposit", - withdraw_label, - 0, /* Index of the one withdrawn coin in the traits. */ - TALER_TESTING_make_wire_details - (USER_ACCOUNT_NUMBER, - exchange_bank_account.details.x_taler_bank.hostname), - order_enc, - GNUNET_TIME_UNIT_ZERO, - AMOUNT_1, - MHD_HTTP_OK)); + (TALER_TESTING_cmd_deposit + ("deposit", + withdraw_label, + 0, /* Index of the one withdrawn coin in the traits. */ + TALER_TESTING_make_wire_details + (USER_ACCOUNT_NUMBER, + exchange_bank_account.details.x_taler_bank.hostname), + order_enc, + GNUNET_TIME_UNIT_ZERO, + AMOUNT_1, + MHD_HTTP_OK)); if (eval_probability (refresh_rate / 100.0)) { @@ -337,23 +342,23 @@ run (void *cls, j); unit[2] = TALER_TESTING_cmd_refresh_melt_with_retry - (TALER_TESTING_cmd_refresh_melt - (melt_label, - withdraw_label, - MHD_HTTP_OK, - NULL)); + (TALER_TESTING_cmd_refresh_melt + (melt_label, + withdraw_label, + MHD_HTTP_OK, + NULL)); unit[3] = TALER_TESTING_cmd_refresh_reveal_with_retry - (TALER_TESTING_cmd_refresh_reveal - (reveal_label, - melt_label, - MHD_HTTP_OK)); + (TALER_TESTING_cmd_refresh_reveal + (reveal_label, + melt_label, + MHD_HTTP_OK)); unit[4] = TALER_TESTING_cmd_refresh_link_with_retry - (TALER_TESTING_cmd_refresh_link - ("refresh-link", - reveal_label, - MHD_HTTP_OK)); + (TALER_TESTING_cmd_refresh_link + ("refresh-link", + reveal_label, + MHD_HTTP_OK)); unit[5] = TALER_TESTING_cmd_end (); } else @@ -402,7 +407,7 @@ launch_fakebank (void *cls) const char *bank_base_url = cls; const char *port; long pnum; - struct TALER_FAKEBANK_Handle * fakebank; + struct TALER_FAKEBANK_Handle *fakebank; port = strrchr (bank_base_url, (unsigned char) ':'); @@ -460,7 +465,8 @@ parallel_benchmark (TALER_TESTING_Main main_cb, NULL == loglev ? "INFO" : loglev, logfile); GNUNET_SCHEDULER_run (&launch_fakebank, - exchange_bank_account.details.x_taler_bank.bank_base_url); + exchange_bank_account.details.x_taler_bank. + bank_base_url); exit (0); } if (-1 == fakebank) @@ -534,9 +540,9 @@ parallel_benchmark (TALER_TESTING_Main main_cb, remote_cmd); GNUNET_assert (NULL != (exchange_slave_pipe = - GNUNET_DISK_pipe (GNUNET_YES, - GNUNET_YES, - 0, 0))); + GNUNET_DISK_pipe (GNUNET_YES, + GNUNET_YES, + 0, 0))); exchange_slave = GNUNET_OS_start_process (GNUNET_NO, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, @@ -586,7 +592,7 @@ parallel_benchmark (TALER_TESTING_Main main_cb, start_time = GNUNET_TIME_absolute_get (); result = GNUNET_OK; - for (unsigned int i=0;iuser_config_file); + cfg_filename = GNUNET_strdup ( + GNUNET_OS_project_data_get ()->user_config_file); cfg = GNUNET_CONFIGURATION_create (); if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, @@ -822,21 +830,22 @@ main (int argc, GNUNET_CONFIGURATION_iterate_sections (cfg, - &pick_exchange_account_cb, - &bank_details_section); + &pick_exchange_account_cb, + &bank_details_section); if (NULL == bank_details_section) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Missing specification of bank account in configuration\n")); + _ ( + "Missing specification of bank account in configuration\n")); return BAD_CONFIG_FILE; } if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string - (cfg, - bank_details_section, - "url", - &exchange_payto_url)) + (cfg, + bank_details_section, + "url", + &exchange_payto_url)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, bank_details_section, @@ -846,10 +855,10 @@ main (int argc, if (TALER_EC_NONE != TALER_WIRE_payto_to_account (exchange_payto_url, - &exchange_bank_account)) + &exchange_bank_account)) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Malformed payto:// URL `%s' in configuration\n"), + _ ("Malformed payto:// URL `%s' in configuration\n"), exchange_payto_url); GNUNET_free (exchange_payto_url); return BAD_CONFIG_FILE; @@ -857,7 +866,8 @@ main (int argc, if (TALER_PAC_X_TALER_BANK != exchange_bank_account.type) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, - _("Malformed payto:// URL `%s' in configuration: x-taler-bank required\n"), + _ ( + "Malformed payto:// URL `%s' in configuration: x-taler-bank required\n"), exchange_payto_url); GNUNET_free (exchange_payto_url); return BAD_CONFIG_FILE; @@ -869,13 +879,13 @@ main (int argc, struct GNUNET_OS_Process *compute_wire_response; compute_wire_response = GNUNET_OS_start_process - (GNUNET_NO, - GNUNET_OS_INHERIT_STD_ALL, - NULL, NULL, NULL, - "taler-exchange-wire", - "taler-exchange-wire", - "-c", cfg_filename, - NULL); + (GNUNET_NO, + GNUNET_OS_INHERIT_STD_ALL, + NULL, NULL, NULL, + "taler-exchange-wire", + "taler-exchange-wire", + "-c", cfg_filename, + NULL); if (NULL == compute_wire_response) { GNUNET_log (GNUNET_ERROR_TYPE_ERROR, @@ -889,8 +899,8 @@ main (int argc, GNUNET_assert (GNUNET_OK == TALER_TESTING_prepare_exchange (cfg_filename, - &auditor_url, - &exchange_url)); + &auditor_url, + &exchange_url)); } else { @@ -952,7 +962,7 @@ main (int argc, if (GNUNET_OK == result) { struct rusage usage; - GNUNET_assert (0 == getrusage(RUSAGE_CHILDREN, &usage)); + GNUNET_assert (0 == getrusage (RUSAGE_CHILDREN, &usage)); fprintf (stdout, "Executed (Withdraw=%u, Deposit=%u, Refresh~=%5.2f) * Reserve=%u * Parallel=%u, operations in %s\n", howmany_coins, @@ -961,16 +971,16 @@ main (int argc, howmany_reserves, howmany_clients, GNUNET_STRINGS_relative_time_to_string - (duration, - GNUNET_NO)); + (duration, + GNUNET_NO)); fprintf (stdout, "(approximately %s/coin)\n", GNUNET_STRINGS_relative_time_to_string - (GNUNET_TIME_relative_divide (duration, - (unsigned long long) howmany_coins * - howmany_reserves * - howmany_clients), - GNUNET_YES)); + (GNUNET_TIME_relative_divide (duration, + (unsigned long long) howmany_coins + * howmany_reserves + * howmany_clients), + GNUNET_YES)); fprintf (stdout, "RAW: %04u %04u %04u %16llu\n", howmany_coins, @@ -978,8 +988,10 @@ main (int argc, howmany_clients, (unsigned long long) duration.rel_value_us); fprintf (stdout, "cpu time: sys %llu user %llu\n", \ - (unsigned long long) (usage.ru_stime.tv_sec * 1000 * 1000 + usage.ru_stime.tv_usec), - (unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000 + usage.ru_utime.tv_usec)); + (unsigned long long) (usage.ru_stime.tv_sec * 1000 * 1000 + + usage.ru_stime.tv_usec), + (unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000 + + usage.ru_utime.tv_usec)); } return (GNUNET_OK == result) ? 0 : result; } -- cgit v1.2.3