2016-05-30 15:08:12 +02:00
|
|
|
/*
|
|
|
|
This file is part of TALER
|
2020-01-11 15:19:56 +01:00
|
|
|
(C) 2014-2020 Taler Systems SA
|
2016-05-30 15:08:12 +02:00
|
|
|
|
2018-07-25 13:26:47 +02:00
|
|
|
TALER is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU Affero General Public License as
|
|
|
|
published by the Free Software Foundation; either version 3, or
|
|
|
|
(at your option) any later version.
|
2016-05-30 15:08:12 +02:00
|
|
|
|
2018-07-25 13:26:47 +02:00
|
|
|
TALER is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
2016-05-30 15:08:12 +02:00
|
|
|
|
2018-07-25 13:26:47 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with TALER; see the file COPYING. If not,
|
|
|
|
see <http://www.gnu.org/licenses/>
|
2016-05-30 15:08:12 +02:00
|
|
|
*/
|
|
|
|
/**
|
2020-01-11 15:19:56 +01:00
|
|
|
* @file benchmark/taler-exchange-benchmark.c
|
2018-07-25 13:26:47 +02:00
|
|
|
* @brief HTTP serving layer intended to perform crypto-work and
|
|
|
|
* communication with the exchange
|
2016-05-30 15:08:12 +02:00
|
|
|
* @author Marcello Stanisci
|
2018-08-10 19:12:57 +02:00
|
|
|
* @author Christian Grothoff
|
2016-05-30 15:08:12 +02:00
|
|
|
*/
|
|
|
|
#include "platform.h"
|
|
|
|
#include <gnunet/gnunet_util_lib.h>
|
|
|
|
#include <microhttpd.h>
|
2018-10-02 17:26:42 +02:00
|
|
|
#include <sys/resource.h>
|
2018-08-06 15:18:29 +02:00
|
|
|
#include "taler_util.h"
|
|
|
|
#include "taler_signatures.h"
|
|
|
|
#include "taler_exchange_service.h"
|
|
|
|
#include "taler_json_lib.h"
|
|
|
|
#include "taler_bank_service.h"
|
|
|
|
#include "taler_fakebank_lib.h"
|
|
|
|
#include "taler_testing_lib.h"
|
|
|
|
#include "taler_error_codes.h"
|
2018-07-25 13:26:47 +02:00
|
|
|
|
|
|
|
/* Error codes. */
|
2019-08-25 16:18:24 +02:00
|
|
|
enum BenchmarkError
|
|
|
|
{
|
2018-07-25 13:26:47 +02:00
|
|
|
MISSING_BANK_URL,
|
|
|
|
FAILED_TO_LAUNCH_BANK,
|
|
|
|
BAD_CLI_ARG,
|
|
|
|
BAD_CONFIG_FILE,
|
|
|
|
NO_CONFIG_FILE_GIVEN
|
2016-06-15 18:19:40 +02:00
|
|
|
};
|
2016-06-15 17:54:36 +02:00
|
|
|
|
2018-08-07 22:10:38 +02:00
|
|
|
|
2016-06-11 16:31:33 +02:00
|
|
|
/**
|
2018-07-25 13:26:47 +02:00
|
|
|
* The whole benchmark is a repetition of a "unit". Each
|
|
|
|
* unit is a array containing a withdraw+deposit operation,
|
|
|
|
* and _possibly_ a refresh of the deposited coin.
|
2016-06-11 16:31:33 +02:00
|
|
|
*/
|
2018-07-25 13:26:47 +02:00
|
|
|
#define UNITY_SIZE 6
|
2016-06-11 16:31:33 +02:00
|
|
|
|
2018-07-25 13:26:47 +02:00
|
|
|
#define FIRST_INSTRUCTION -1
|
2016-05-30 18:45:57 +02:00
|
|
|
|
2018-07-27 14:47:02 +02:00
|
|
|
|
2018-08-19 00:49:16 +02:00
|
|
|
/**
|
|
|
|
* What mode should the benchmark run in?
|
|
|
|
*/
|
2019-08-25 16:18:24 +02:00
|
|
|
enum BenchmarkMode
|
|
|
|
{
|
2018-08-19 00:49:16 +02:00
|
|
|
/**
|
|
|
|
* Run as client (with fakebank), also starts a remote exchange.
|
|
|
|
*/
|
|
|
|
MODE_CLIENT = 1,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run the the exchange.
|
|
|
|
*/
|
|
|
|
MODE_EXCHANGE = 2,
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run both, for a local benchmark.
|
|
|
|
*/
|
|
|
|
MODE_BOTH = 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-07-27 14:47:02 +02:00
|
|
|
/**
|
|
|
|
* Hold information regarding which bank has the exchange account.
|
|
|
|
*/
|
2020-01-17 23:40:33 +01:00
|
|
|
static struct TALER_BANK_AuthenticationData exchange_bank_account;
|
2016-05-30 18:45:57 +02:00
|
|
|
|
2020-01-13 00:27:48 +01:00
|
|
|
/**
|
|
|
|
* Configuration of our exchange.
|
|
|
|
*/
|
|
|
|
static struct TALER_TESTING_ExchangeConfiguration ec;
|
|
|
|
|
2020-01-11 15:19:56 +01:00
|
|
|
/**
|
|
|
|
* Hold information about a user at the bank.
|
|
|
|
*/
|
2020-01-19 17:03:19 +01:00
|
|
|
static char *user_payto_uri;
|
2020-01-11 15:19:56 +01:00
|
|
|
|
2016-06-15 16:04:29 +02:00
|
|
|
/**
|
2018-07-25 13:26:47 +02:00
|
|
|
* Time snapshot taken right before executing the CMDs.
|
2016-06-15 16:04:29 +02:00
|
|
|
*/
|
2018-07-25 13:26:47 +02:00
|
|
|
static struct GNUNET_TIME_Absolute start_time;
|
2016-06-15 16:04:29 +02:00
|
|
|
|
2016-06-07 16:58:55 +02:00
|
|
|
/**
|
2018-07-25 13:26:47 +02:00
|
|
|
* Benchmark duration time taken right after the CMD interpreter
|
|
|
|
* returns.
|
2016-06-07 16:58:55 +02:00
|
|
|
*/
|
2018-07-25 13:26:47 +02:00
|
|
|
static struct GNUNET_TIME_Relative duration;
|
2016-06-07 16:58:55 +02:00
|
|
|
|
2020-01-19 17:03:30 +01:00
|
|
|
/**
|
|
|
|
* Array of all the commands the benchmark is running.
|
|
|
|
*/
|
|
|
|
static struct TALER_TESTING_Command *all_commands;
|
|
|
|
|
2020-03-19 21:44:54 +01:00
|
|
|
/**
|
|
|
|
* Name of our configuration file.
|
|
|
|
*/
|
|
|
|
static char *cfg_filename;
|
|
|
|
|
2016-06-11 17:35:15 +02:00
|
|
|
/**
|
2018-07-25 13:26:47 +02:00
|
|
|
* Exit code.
|
2016-06-11 17:35:15 +02:00
|
|
|
*/
|
2021-01-07 10:40:01 +01:00
|
|
|
static enum GNUNET_GenericReturnValue result;
|
2016-06-15 18:19:40 +02:00
|
|
|
|
2020-03-19 21:44:54 +01:00
|
|
|
/**
|
|
|
|
* Use the fakebank instead of the Python bank.
|
|
|
|
*/
|
|
|
|
static int use_fakebank;
|
|
|
|
|
2016-06-15 18:19:40 +02:00
|
|
|
/**
|
2018-08-11 02:48:49 +02:00
|
|
|
* How many coins we want to create per client and reserve.
|
2016-09-23 16:52:13 +02:00
|
|
|
*/
|
2018-07-25 13:26:47 +02:00
|
|
|
static unsigned int howmany_coins = 1;
|
2016-06-15 18:19:40 +02:00
|
|
|
|
2018-08-11 02:48:49 +02:00
|
|
|
/**
|
|
|
|
* How many reserves we want to create per client.
|
|
|
|
*/
|
|
|
|
static unsigned int howmany_reserves = 1;
|
|
|
|
|
2018-10-02 21:08:59 +02:00
|
|
|
/**
|
|
|
|
* Probability (in percent) of refreshing per spent coin.
|
|
|
|
*/
|
|
|
|
static unsigned int refresh_rate = 10;
|
|
|
|
|
2018-08-07 22:10:38 +02:00
|
|
|
/**
|
|
|
|
* How many clients we want to create.
|
|
|
|
*/
|
|
|
|
static unsigned int howmany_clients = 1;
|
|
|
|
|
2020-03-19 21:44:54 +01:00
|
|
|
/**
|
|
|
|
* Bank configuration to use.
|
|
|
|
*/
|
|
|
|
static struct TALER_TESTING_BankConfiguration bc;
|
|
|
|
|
2016-06-15 18:19:40 +02:00
|
|
|
/**
|
2018-07-25 13:26:47 +02:00
|
|
|
* Log level used during the run.
|
2016-06-15 18:19:40 +02:00
|
|
|
*/
|
2018-07-25 13:26:47 +02:00
|
|
|
static char *loglev;
|
2016-06-15 18:19:40 +02:00
|
|
|
|
|
|
|
/**
|
2018-07-25 13:26:47 +02:00
|
|
|
* Log file.
|
2016-06-15 18:19:40 +02:00
|
|
|
*/
|
2018-07-25 13:26:47 +02:00
|
|
|
static char *logfile;
|
2016-06-15 18:19:40 +02:00
|
|
|
|
2018-08-19 00:49:16 +02:00
|
|
|
/**
|
|
|
|
* Benchmarking mode (run as client, exchange, both) as string.
|
|
|
|
*/
|
|
|
|
static char *mode_str;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Benchmarking mode (run as client, exchange, both).
|
|
|
|
*/
|
|
|
|
static enum BenchmarkMode mode;
|
|
|
|
|
2016-06-15 18:19:40 +02:00
|
|
|
/**
|
2020-02-04 21:59:43 +01:00
|
|
|
* Configuration.
|
2016-06-15 18:19:40 +02:00
|
|
|
*/
|
2020-02-04 21:59:43 +01:00
|
|
|
static struct GNUNET_CONFIGURATION_Handle *cfg;
|
2016-06-15 18:19:40 +02:00
|
|
|
|
2020-03-20 18:38:57 +01:00
|
|
|
/**
|
|
|
|
* Should we create all of the reserves at the beginning?
|
|
|
|
*/
|
|
|
|
static int reserves_first;
|
|
|
|
|
2017-12-10 19:00:19 +01:00
|
|
|
/**
|
2018-07-25 13:26:47 +02:00
|
|
|
* Currency used.
|
2017-12-10 19:00:19 +01:00
|
|
|
*/
|
2018-07-25 13:26:47 +02:00
|
|
|
static char *currency;
|
2017-12-10 19:00:19 +01:00
|
|
|
|
2018-08-19 00:49:16 +02:00
|
|
|
/**
|
|
|
|
* Remote host that runs the exchange.
|
|
|
|
*/
|
|
|
|
static char *remote_host;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remote benchmarking directory.
|
|
|
|
*/
|
|
|
|
static char *remote_dir;
|
|
|
|
|
2020-01-19 22:23:57 +01:00
|
|
|
/**
|
|
|
|
* Array of command labels.
|
|
|
|
*/
|
|
|
|
static char **labels;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Length of #labels.
|
|
|
|
*/
|
|
|
|
static unsigned int label_len;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Offset in #labels.
|
|
|
|
*/
|
|
|
|
static unsigned int label_off;
|
|
|
|
|
2018-08-23 22:47:50 +02:00
|
|
|
/**
|
|
|
|
* Don't kill exchange/fakebank/wirewatch until
|
|
|
|
* requested by the user explicitly.
|
|
|
|
*/
|
|
|
|
static int linger;
|
|
|
|
|
2020-03-20 02:36:50 +01:00
|
|
|
/**
|
|
|
|
* Performance counters.
|
|
|
|
*/
|
|
|
|
static struct TALER_TESTING_Timer timings[] = {
|
|
|
|
{ .prefix = "createreserve" },
|
|
|
|
{ .prefix = "withdraw" },
|
|
|
|
{ .prefix = "deposit" },
|
|
|
|
{ .prefix = "melt" },
|
|
|
|
{ .prefix = "reveal" },
|
|
|
|
{ .prefix = "link" },
|
|
|
|
{ .prefix = NULL }
|
|
|
|
};
|
|
|
|
|
2016-06-15 15:09:57 +02:00
|
|
|
|
2020-01-19 22:23:57 +01:00
|
|
|
/**
|
|
|
|
* Add label to the #labels table and return it.
|
|
|
|
*
|
|
|
|
* @param label string to add to the table
|
|
|
|
* @return same string, now stored in the table
|
|
|
|
*/
|
|
|
|
const char *
|
|
|
|
add_label (char *label)
|
|
|
|
{
|
|
|
|
if (label_off == label_len)
|
|
|
|
GNUNET_array_grow (labels,
|
|
|
|
label_len,
|
|
|
|
label_len * 2 + 4);
|
|
|
|
labels[label_off++] = label;
|
|
|
|
return label;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-01-17 23:40:33 +01:00
|
|
|
static struct TALER_TESTING_Command
|
2020-01-19 22:23:57 +01:00
|
|
|
cmd_transfer_to_exchange (const char *label,
|
|
|
|
const char *amount)
|
2020-01-17 23:40:33 +01:00
|
|
|
{
|
|
|
|
return TALER_TESTING_cmd_admin_add_incoming_retry
|
2020-01-19 15:36:43 +01:00
|
|
|
(TALER_TESTING_cmd_admin_add_incoming (label,
|
|
|
|
amount,
|
2020-01-18 04:20:29 +01:00
|
|
|
&exchange_bank_account,
|
2020-01-19 17:03:19 +01:00
|
|
|
user_payto_uri));
|
2020-01-17 23:40:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-27 14:47:02 +02:00
|
|
|
/**
|
|
|
|
* Decide which exchange account is going to be
|
|
|
|
* used to address a wire transfer to. Used at
|
|
|
|
* withdrawal time.
|
|
|
|
*
|
|
|
|
* @param cls closure
|
|
|
|
* @param section section name.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
pick_exchange_account_cb (void *cls,
|
|
|
|
const char *section)
|
|
|
|
{
|
2020-01-19 18:48:14 +01:00
|
|
|
if (0 == strncasecmp ("exchange-account-",
|
2018-08-19 00:49:16 +02:00
|
|
|
section,
|
2020-01-19 18:48:14 +01:00
|
|
|
strlen ("exchange-account-")))
|
2018-07-27 14:47:02 +02:00
|
|
|
{
|
|
|
|
const char **s = cls;
|
2019-06-03 10:44:57 +02:00
|
|
|
|
2018-07-27 14:47:02 +02:00
|
|
|
*s = section;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-07 22:10:38 +02:00
|
|
|
|
2016-06-15 15:09:57 +02:00
|
|
|
/**
|
2016-09-23 16:52:13 +02:00
|
|
|
* Throw a weighted coin with @a probability.
|
|
|
|
*
|
2018-07-25 13:26:47 +02:00
|
|
|
* @return #GNUNET_OK with @a probability,
|
|
|
|
* #GNUNET_NO with 1 - @a probability
|
2016-06-15 15:09:57 +02:00
|
|
|
*/
|
2016-06-04 01:29:42 +02:00
|
|
|
static unsigned int
|
|
|
|
eval_probability (float probability)
|
|
|
|
{
|
2016-06-15 15:09:57 +02:00
|
|
|
uint64_t random;
|
2016-06-04 01:29:42 +02:00
|
|
|
float random_01;
|
2016-06-06 23:53:54 +02:00
|
|
|
|
2016-06-15 15:09:57 +02:00
|
|
|
random = GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
|
2019-08-25 16:18:24 +02:00
|
|
|
UINT64_MAX);
|
2016-06-15 15:09:57 +02:00
|
|
|
random_01 = (double) random / UINT64_MAX;
|
|
|
|
return (random_01 <= probability) ? GNUNET_OK : GNUNET_NO;
|
2016-06-04 01:29:42 +02:00
|
|
|
}
|
|
|
|
|
2016-06-06 23:53:54 +02:00
|
|
|
|
2016-06-04 01:29:42 +02:00
|
|
|
/**
|
2020-01-19 17:03:30 +01:00
|
|
|
* Actual commands construction and execution.
|
|
|
|
*
|
|
|
|
* @param cls unused
|
|
|
|
* @param is interpreter to run commands with
|
2016-06-15 16:36:17 +02:00
|
|
|
*/
|
|
|
|
static void
|
2018-07-25 13:26:47 +02:00
|
|
|
run (void *cls,
|
|
|
|
struct TALER_TESTING_Interpreter *is)
|
2016-06-15 16:36:17 +02:00
|
|
|
{
|
2018-07-25 13:26:47 +02:00
|
|
|
struct TALER_Amount total_reserve_amount;
|
|
|
|
struct TALER_Amount withdraw_fee;
|
|
|
|
char *withdraw_fee_str;
|
2020-01-19 17:03:30 +01:00
|
|
|
char *amount_5;
|
|
|
|
char *amount_4;
|
|
|
|
char *amount_1;
|
2018-08-19 00:49:16 +02:00
|
|
|
|
2019-09-10 05:48:34 +02:00
|
|
|
(void) cls;
|
2020-01-19 17:03:30 +01:00
|
|
|
all_commands = GNUNET_new_array (howmany_reserves * (1 /* Withdraw block */
|
|
|
|
+ howmany_coins) /* All units */
|
2020-03-20 02:36:50 +01:00
|
|
|
+ 1 /* stat CMD */
|
2020-01-19 17:03:30 +01:00
|
|
|
+ 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);
|
2021-07-23 13:02:04 +02:00
|
|
|
GNUNET_assert (GNUNET_OK == TALER_amount_set_zero (currency,
|
2019-08-25 16:18:24 +02:00
|
|
|
&total_reserve_amount));
|
2018-07-25 13:26:47 +02:00
|
|
|
total_reserve_amount.value = 5 * howmany_coins;
|
|
|
|
GNUNET_asprintf (&withdraw_fee_str,
|
|
|
|
"%s:0.1",
|
|
|
|
currency);
|
2019-06-03 10:44:57 +02:00
|
|
|
GNUNET_assert (GNUNET_OK ==
|
|
|
|
TALER_string_to_amount (withdraw_fee_str,
|
|
|
|
&withdraw_fee));
|
2018-07-25 13:26:47 +02:00
|
|
|
for (unsigned int i = 0; i < howmany_coins; i++)
|
2020-04-08 23:52:01 +02:00
|
|
|
GNUNET_assert (0 <=
|
2019-06-03 10:44:57 +02:00
|
|
|
TALER_amount_add (&total_reserve_amount,
|
|
|
|
&total_reserve_amount,
|
|
|
|
&withdraw_fee));
|
2018-08-11 02:48:49 +02:00
|
|
|
for (unsigned int j = 0; j < howmany_reserves; j++)
|
2018-07-25 13:26:47 +02:00
|
|
|
{
|
2018-08-11 02:48:49 +02:00
|
|
|
char *create_reserve_label;
|
2018-07-25 13:26:47 +02:00
|
|
|
|
2018-08-11 02:48:49 +02:00
|
|
|
GNUNET_asprintf (&create_reserve_label,
|
2020-03-20 02:36:50 +01:00
|
|
|
"createreserve-%u",
|
2018-08-11 02:48:49 +02:00
|
|
|
j);
|
2017-12-10 19:00:19 +01:00
|
|
|
{
|
2018-08-11 02:48:49 +02:00
|
|
|
struct TALER_TESTING_Command make_reserve[] = {
|
2020-01-19 22:23:57 +01:00
|
|
|
cmd_transfer_to_exchange (add_label (create_reserve_label),
|
|
|
|
TALER_amount2s (&total_reserve_amount)),
|
2018-08-11 02:48:49 +02:00
|
|
|
TALER_TESTING_cmd_end ()
|
|
|
|
};
|
|
|
|
char *batch_label;
|
|
|
|
|
|
|
|
GNUNET_asprintf (&batch_label,
|
|
|
|
"batch-start-%u",
|
|
|
|
j);
|
2020-03-20 12:34:59 +01:00
|
|
|
all_commands[reserves_first
|
|
|
|
? j
|
|
|
|
: j * (howmany_coins + 1)]
|
2020-01-19 22:23:57 +01:00
|
|
|
= TALER_TESTING_cmd_batch (add_label (batch_label),
|
2018-08-11 02:48:49 +02:00
|
|
|
make_reserve);
|
|
|
|
}
|
|
|
|
for (unsigned int i = 0; i < howmany_coins; i++)
|
|
|
|
{
|
|
|
|
char *withdraw_label;
|
|
|
|
char *order_enc;
|
|
|
|
struct TALER_TESTING_Command unit[UNITY_SIZE];
|
|
|
|
char *unit_label;
|
2020-03-20 02:36:50 +01:00
|
|
|
const char *wl;
|
2018-08-11 02:48:49 +02:00
|
|
|
|
|
|
|
GNUNET_asprintf (&withdraw_label,
|
|
|
|
"withdraw-%u-%u",
|
|
|
|
i,
|
|
|
|
j);
|
2020-03-20 02:36:50 +01:00
|
|
|
wl = add_label (withdraw_label);
|
2018-08-11 02:48:49 +02:00
|
|
|
GNUNET_asprintf (&order_enc,
|
|
|
|
"{\"nonce\": %llu}",
|
2020-10-13 12:34:57 +02:00
|
|
|
((unsigned long long) i) + (howmany_coins
|
|
|
|
* (unsigned long long) j));
|
2018-08-11 02:48:49 +02:00
|
|
|
unit[0] =
|
2020-01-19 17:25:45 +01:00
|
|
|
TALER_TESTING_cmd_withdraw_with_retry
|
2020-03-20 02:36:50 +01:00
|
|
|
(TALER_TESTING_cmd_withdraw_amount (wl,
|
2020-01-19 17:25:45 +01:00
|
|
|
create_reserve_label,
|
|
|
|
amount_5,
|
|
|
|
MHD_HTTP_OK));
|
2018-08-11 11:29:02 +02:00
|
|
|
unit[1] =
|
|
|
|
TALER_TESTING_cmd_deposit_with_retry
|
2020-01-19 17:03:30 +01:00
|
|
|
(TALER_TESTING_cmd_deposit ("deposit",
|
2020-03-20 02:36:50 +01:00
|
|
|
wl,
|
2020-01-19 17:03:30 +01:00
|
|
|
0, /* Index of the one withdrawn coin in the traits. */
|
2020-01-19 17:04:35 +01:00
|
|
|
user_payto_uri,
|
2020-01-19 22:23:57 +01:00
|
|
|
add_label (order_enc),
|
2020-01-19 17:03:30 +01:00
|
|
|
GNUNET_TIME_UNIT_ZERO,
|
|
|
|
amount_1,
|
|
|
|
MHD_HTTP_OK));
|
2018-10-02 21:08:59 +02:00
|
|
|
if (eval_probability (refresh_rate / 100.0))
|
2018-08-11 02:48:49 +02:00
|
|
|
{
|
|
|
|
char *melt_label;
|
|
|
|
char *reveal_label;
|
2020-03-20 02:36:50 +01:00
|
|
|
const char *ml;
|
|
|
|
const char *rl;
|
2018-08-11 02:48:49 +02:00
|
|
|
|
|
|
|
GNUNET_asprintf (&melt_label,
|
2020-03-20 02:36:50 +01:00
|
|
|
"melt-%u-%u",
|
2018-08-11 02:48:49 +02:00
|
|
|
i,
|
|
|
|
j);
|
2020-03-20 02:36:50 +01:00
|
|
|
ml = add_label (melt_label);
|
2018-08-11 02:48:49 +02:00
|
|
|
GNUNET_asprintf (&reveal_label,
|
2020-03-20 02:36:50 +01:00
|
|
|
"reveal-%u-%u",
|
2018-08-11 02:48:49 +02:00
|
|
|
i,
|
|
|
|
j);
|
2020-03-20 02:36:50 +01:00
|
|
|
rl = add_label (reveal_label);
|
2018-08-11 11:29:02 +02:00
|
|
|
unit[2] =
|
2020-02-29 16:42:10 +01:00
|
|
|
TALER_TESTING_cmd_melt_with_retry
|
2020-03-20 02:36:50 +01:00
|
|
|
(TALER_TESTING_cmd_melt (ml,
|
|
|
|
wl,
|
|
|
|
MHD_HTTP_OK,
|
|
|
|
NULL));
|
2018-08-11 11:29:02 +02:00
|
|
|
unit[3] =
|
|
|
|
TALER_TESTING_cmd_refresh_reveal_with_retry
|
2020-03-20 02:36:50 +01:00
|
|
|
(TALER_TESTING_cmd_refresh_reveal (rl,
|
|
|
|
ml,
|
|
|
|
MHD_HTTP_OK));
|
2018-08-11 11:29:02 +02:00
|
|
|
unit[4] =
|
|
|
|
TALER_TESTING_cmd_refresh_link_with_retry
|
2020-03-20 02:36:50 +01:00
|
|
|
(TALER_TESTING_cmd_refresh_link ("link",
|
|
|
|
rl,
|
|
|
|
MHD_HTTP_OK));
|
2018-08-11 02:48:49 +02:00
|
|
|
unit[5] = TALER_TESTING_cmd_end ();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
unit[2] = TALER_TESTING_cmd_end ();
|
|
|
|
|
|
|
|
GNUNET_asprintf (&unit_label,
|
|
|
|
"unit-%u-%u",
|
|
|
|
i,
|
|
|
|
j);
|
2020-03-20 12:34:59 +01:00
|
|
|
all_commands[reserves_first
|
|
|
|
? howmany_reserves + j * howmany_coins + i
|
|
|
|
: j * (howmany_coins + 1) + (1 + i)]
|
2020-01-19 22:23:57 +01:00
|
|
|
= TALER_TESTING_cmd_batch (add_label (unit_label),
|
2018-08-11 02:48:49 +02:00
|
|
|
unit);
|
|
|
|
}
|
2018-07-25 13:26:47 +02:00
|
|
|
}
|
2018-08-11 02:48:49 +02:00
|
|
|
all_commands[howmany_reserves * (1 + howmany_coins)]
|
2020-03-20 02:36:50 +01:00
|
|
|
= TALER_TESTING_cmd_stat (timings);
|
|
|
|
all_commands[howmany_reserves * (1 + howmany_coins) + 1]
|
2018-08-11 02:48:49 +02:00
|
|
|
= TALER_TESTING_cmd_end ();
|
2018-08-10 22:31:46 +02:00
|
|
|
TALER_TESTING_run2 (is,
|
|
|
|
all_commands,
|
|
|
|
GNUNET_TIME_UNIT_FOREVER_REL); /* no timeout */
|
2020-01-19 17:25:45 +01:00
|
|
|
GNUNET_free (amount_1);
|
|
|
|
GNUNET_free (amount_4);
|
|
|
|
GNUNET_free (amount_5);
|
|
|
|
GNUNET_free (withdraw_fee_str);
|
2021-01-07 10:40:01 +01:00
|
|
|
result = GNUNET_OK;
|
2016-06-03 01:23:16 +02:00
|
|
|
}
|
|
|
|
|
2018-08-07 22:10:38 +02:00
|
|
|
|
2020-03-20 02:36:50 +01:00
|
|
|
/**
|
|
|
|
* Print performance statistics for this process.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
print_stats (void)
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; NULL != timings[i].prefix; i++)
|
2020-03-20 18:38:57 +01:00
|
|
|
{
|
|
|
|
char *total;
|
|
|
|
char *latency;
|
|
|
|
|
|
|
|
total = GNUNET_strdup (
|
|
|
|
GNUNET_STRINGS_relative_time_to_string (timings[i].total_duration,
|
|
|
|
GNUNET_YES));
|
|
|
|
latency = GNUNET_strdup (
|
|
|
|
GNUNET_STRINGS_relative_time_to_string (timings[i].success_latency,
|
|
|
|
GNUNET_YES));
|
2020-03-20 02:36:50 +01:00
|
|
|
fprintf (stderr,
|
2020-03-20 18:38:57 +01:00
|
|
|
"%s-%d took %s in total with %s for latency for %u executions (%u repeats)\n",
|
2020-03-20 02:36:50 +01:00
|
|
|
timings[i].prefix,
|
|
|
|
(int) getpid (),
|
2020-03-20 18:38:57 +01:00
|
|
|
total,
|
|
|
|
latency,
|
|
|
|
timings[i].num_commands,
|
|
|
|
timings[i].num_retries);
|
|
|
|
GNUNET_free (total);
|
|
|
|
GNUNET_free (latency);
|
|
|
|
}
|
2020-03-20 02:36:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-09 19:47:23 +02:00
|
|
|
/**
|
|
|
|
* Stop the fakebank.
|
|
|
|
*
|
|
|
|
* @param cls fakebank handle
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
stop_fakebank (void *cls)
|
|
|
|
{
|
|
|
|
struct TALER_FAKEBANK_Handle *fakebank = cls;
|
|
|
|
|
|
|
|
TALER_FAKEBANK_stop (fakebank);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start the fakebank.
|
|
|
|
*
|
2020-01-19 15:36:43 +01:00
|
|
|
* @param cls NULL
|
2018-08-09 19:47:23 +02:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
launch_fakebank (void *cls)
|
|
|
|
{
|
2019-08-25 16:18:24 +02:00
|
|
|
struct TALER_FAKEBANK_Handle *fakebank;
|
2018-08-09 19:47:23 +02:00
|
|
|
|
2020-01-19 15:36:43 +01:00
|
|
|
(void) cls;
|
|
|
|
fakebank
|
2020-02-04 21:59:43 +01:00
|
|
|
= TALER_TESTING_run_fakebank (exchange_bank_account.wire_gateway_url,
|
|
|
|
currency);
|
2018-08-09 19:47:23 +02:00
|
|
|
if (NULL == fakebank)
|
|
|
|
{
|
|
|
|
GNUNET_break (0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
GNUNET_SCHEDULER_add_shutdown (&stop_fakebank,
|
|
|
|
fakebank);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-07 22:10:38 +02:00
|
|
|
/**
|
|
|
|
* Run the benchmark in parallel in many (client) processes
|
|
|
|
* and summarize result.
|
|
|
|
*
|
|
|
|
* @param main_cb main function to run per process
|
|
|
|
* @param main_cb_cls closure for @a main_cb
|
|
|
|
* @param config_file configuration file to use
|
|
|
|
* @return #GNUNET_OK on success
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
parallel_benchmark (TALER_TESTING_Main main_cb,
|
|
|
|
void *main_cb_cls,
|
2020-01-13 00:27:48 +01:00
|
|
|
const char *config_file)
|
2018-08-07 22:10:38 +02:00
|
|
|
{
|
2021-01-07 10:40:01 +01:00
|
|
|
enum GNUNET_GenericReturnValue result = GNUNET_OK;
|
2018-08-07 22:10:38 +02:00
|
|
|
pid_t cpids[howmany_clients];
|
2018-08-19 00:49:16 +02:00
|
|
|
pid_t fakebank = -1;
|
2018-08-07 22:10:38 +02:00
|
|
|
int wstatus;
|
2020-03-19 21:44:54 +01:00
|
|
|
struct GNUNET_OS_Process *bankd = NULL;
|
2020-03-19 16:14:01 +01:00
|
|
|
struct GNUNET_OS_Process *auditord = NULL;
|
2018-08-19 00:49:16 +02:00
|
|
|
struct GNUNET_OS_Process *exchanged = NULL;
|
|
|
|
struct GNUNET_OS_Process *wirewatch = NULL;
|
|
|
|
struct GNUNET_OS_Process *exchange_slave = NULL;
|
2019-05-01 20:52:43 +02:00
|
|
|
struct GNUNET_DISK_PipeHandle *exchange_slave_pipe;
|
2018-08-10 13:09:12 +02:00
|
|
|
|
2018-08-19 00:49:16 +02:00
|
|
|
if ( (MODE_CLIENT == mode) || (MODE_BOTH == mode) )
|
2018-08-10 13:09:12 +02:00
|
|
|
{
|
2020-03-19 21:44:54 +01:00
|
|
|
if (use_fakebank)
|
2018-08-19 00:49:16 +02:00
|
|
|
{
|
2020-03-19 21:44:54 +01:00
|
|
|
/* start fakebank */
|
|
|
|
fakebank = fork ();
|
|
|
|
if (0 == fakebank)
|
|
|
|
{
|
|
|
|
GNUNET_log_setup ("benchmark-fakebank",
|
|
|
|
NULL == loglev ? "INFO" : loglev,
|
|
|
|
logfile);
|
|
|
|
GNUNET_SCHEDULER_run (&launch_fakebank,
|
|
|
|
NULL);
|
|
|
|
exit (0);
|
|
|
|
}
|
|
|
|
if (-1 == fakebank)
|
|
|
|
{
|
|
|
|
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
|
|
|
|
"fork");
|
|
|
|
return GNUNET_SYSERR;
|
|
|
|
}
|
2018-08-19 00:49:16 +02:00
|
|
|
}
|
2020-03-19 21:44:54 +01:00
|
|
|
else
|
2018-08-19 00:49:16 +02:00
|
|
|
{
|
2020-03-19 21:44:54 +01:00
|
|
|
/* start bank */
|
|
|
|
if (GNUNET_OK !=
|
|
|
|
TALER_TESTING_prepare_bank (cfg_filename,
|
|
|
|
GNUNET_NO,
|
|
|
|
"exchange-account-2",
|
|
|
|
&bc))
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
bankd = TALER_TESTING_run_bank (cfg_filename,
|
|
|
|
"http://localhost:8082/");
|
|
|
|
if (NULL == bankd)
|
|
|
|
return 77;
|
2018-08-19 00:49:16 +02:00
|
|
|
}
|
2018-08-10 13:09:12 +02:00
|
|
|
}
|
2018-08-09 10:33:21 +02:00
|
|
|
|
2018-08-19 00:49:16 +02:00
|
|
|
if ( (MODE_EXCHANGE == mode) || (MODE_BOTH == mode) )
|
2018-08-10 13:09:12 +02:00
|
|
|
{
|
2018-08-19 00:49:16 +02:00
|
|
|
/* start exchange */
|
2020-07-17 22:18:57 +02:00
|
|
|
exchanged = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
|
2018-08-19 00:49:16 +02:00
|
|
|
NULL, NULL, NULL,
|
|
|
|
"taler-exchange-httpd",
|
|
|
|
"taler-exchange-httpd",
|
|
|
|
"-c", config_file,
|
|
|
|
"-C",
|
|
|
|
NULL);
|
|
|
|
if ( (NULL == exchanged) && (MODE_BOTH == mode) )
|
|
|
|
{
|
2020-03-19 21:44:54 +01:00
|
|
|
if (-1 != fakebank)
|
|
|
|
{
|
|
|
|
kill (fakebank,
|
|
|
|
SIGTERM);
|
|
|
|
waitpid (fakebank,
|
|
|
|
&wstatus,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
if (NULL != bankd)
|
|
|
|
{
|
|
|
|
GNUNET_OS_process_kill (bankd,
|
|
|
|
SIGTERM);
|
|
|
|
GNUNET_OS_process_destroy (bankd);
|
|
|
|
}
|
2018-08-19 00:49:16 +02:00
|
|
|
return 77;
|
|
|
|
}
|
2020-03-19 16:14:01 +01:00
|
|
|
/* start auditor */
|
2020-07-17 22:18:57 +02:00
|
|
|
auditord = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
|
2020-03-19 16:14:01 +01:00
|
|
|
NULL, NULL, NULL,
|
|
|
|
"taler-auditor-httpd",
|
|
|
|
"taler-auditor-httpd",
|
|
|
|
"-c", config_file,
|
|
|
|
NULL);
|
|
|
|
if (NULL == auditord)
|
|
|
|
{
|
|
|
|
GNUNET_OS_process_kill (exchanged,
|
|
|
|
SIGTERM);
|
|
|
|
if (MODE_BOTH == mode)
|
|
|
|
{
|
2020-03-19 21:44:54 +01:00
|
|
|
if (-1 != fakebank)
|
|
|
|
{
|
|
|
|
kill (fakebank,
|
|
|
|
SIGTERM);
|
|
|
|
waitpid (fakebank,
|
|
|
|
&wstatus,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
if (NULL != bankd)
|
|
|
|
{
|
|
|
|
GNUNET_OS_process_kill (bankd,
|
|
|
|
SIGTERM);
|
|
|
|
GNUNET_OS_process_destroy (bankd);
|
|
|
|
}
|
2020-03-19 16:14:01 +01:00
|
|
|
}
|
|
|
|
GNUNET_OS_process_destroy (exchanged);
|
|
|
|
return 77;
|
|
|
|
}
|
2018-08-19 00:49:16 +02:00
|
|
|
/* start exchange wirewatch */
|
2020-07-17 22:18:57 +02:00
|
|
|
wirewatch = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
|
2018-08-19 00:49:16 +02:00
|
|
|
NULL, NULL, NULL,
|
|
|
|
"taler-exchange-wirewatch",
|
|
|
|
"taler-exchange-wirewatch",
|
|
|
|
"-c", config_file,
|
|
|
|
NULL);
|
|
|
|
if (NULL == wirewatch)
|
|
|
|
{
|
2020-03-19 16:14:01 +01:00
|
|
|
GNUNET_OS_process_kill (auditord,
|
|
|
|
SIGTERM);
|
2018-08-19 00:49:16 +02:00
|
|
|
GNUNET_OS_process_kill (exchanged,
|
|
|
|
SIGTERM);
|
|
|
|
if (MODE_BOTH == mode)
|
|
|
|
{
|
2020-03-19 21:44:54 +01:00
|
|
|
if (-1 != fakebank)
|
|
|
|
{
|
|
|
|
kill (fakebank,
|
|
|
|
SIGTERM);
|
|
|
|
waitpid (fakebank,
|
|
|
|
&wstatus,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
if (NULL != bankd)
|
|
|
|
{
|
|
|
|
GNUNET_OS_process_kill (bankd,
|
|
|
|
SIGTERM);
|
|
|
|
GNUNET_OS_process_destroy (bankd);
|
|
|
|
}
|
2018-08-19 00:49:16 +02:00
|
|
|
}
|
|
|
|
GNUNET_OS_process_destroy (exchanged);
|
|
|
|
return 77;
|
|
|
|
}
|
2018-08-10 13:09:12 +02:00
|
|
|
}
|
2018-08-19 00:49:16 +02:00
|
|
|
|
|
|
|
if (MODE_CLIENT == mode)
|
2018-08-09 10:33:21 +02:00
|
|
|
{
|
2018-08-19 00:49:16 +02:00
|
|
|
char *remote_cmd;
|
|
|
|
|
|
|
|
GNUNET_asprintf (&remote_cmd,
|
|
|
|
("cd '%s'; "
|
|
|
|
"taler-exchange-benchmark --mode=exchange -c '%s'"),
|
|
|
|
remote_dir,
|
|
|
|
config_file);
|
|
|
|
|
2019-03-13 04:30:07 +01:00
|
|
|
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
|
|
|
|
"remote command: %s\n",
|
|
|
|
remote_cmd);
|
2018-08-19 00:49:16 +02:00
|
|
|
|
2019-05-01 20:52:43 +02:00
|
|
|
GNUNET_assert (NULL != (exchange_slave_pipe =
|
2020-07-18 00:44:59 +02:00
|
|
|
GNUNET_DISK_pipe (GNUNET_DISK_PF_BLOCKING_RW)));
|
2019-05-01 20:52:43 +02:00
|
|
|
|
2020-07-17 22:18:57 +02:00
|
|
|
exchange_slave = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
|
2019-05-01 20:52:43 +02:00
|
|
|
exchange_slave_pipe, NULL, NULL,
|
2018-08-19 00:49:16 +02:00
|
|
|
"ssh",
|
|
|
|
"ssh",
|
|
|
|
/* Don't ask for pw/passphrase, rather fail */
|
|
|
|
"-oBatchMode=yes",
|
|
|
|
remote_host,
|
|
|
|
remote_cmd,
|
|
|
|
NULL);
|
|
|
|
GNUNET_free (remote_cmd);
|
2018-08-09 10:33:21 +02:00
|
|
|
}
|
2018-08-19 00:49:16 +02:00
|
|
|
|
|
|
|
/* We always wait for the exchange, no matter if it's running locally or
|
|
|
|
remotely */
|
2020-01-13 00:27:48 +01:00
|
|
|
if (0 != TALER_TESTING_wait_exchange_ready (ec.exchange_url))
|
2018-08-09 19:47:23 +02:00
|
|
|
{
|
2019-03-13 04:30:07 +01:00
|
|
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
|
|
|
"Failed to detect running exchange at `%s'\n",
|
2020-01-13 00:27:48 +01:00
|
|
|
ec.exchange_url);
|
2018-08-10 13:09:12 +02:00
|
|
|
GNUNET_OS_process_kill (exchanged,
|
|
|
|
SIGTERM);
|
2018-08-19 00:49:16 +02:00
|
|
|
if ( (MODE_BOTH == mode) || (MODE_CLIENT == mode))
|
|
|
|
{
|
2020-03-19 21:44:54 +01:00
|
|
|
if (-1 != fakebank)
|
|
|
|
{
|
|
|
|
kill (fakebank,
|
|
|
|
SIGTERM);
|
|
|
|
waitpid (fakebank,
|
|
|
|
&wstatus,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
if (NULL != bankd)
|
|
|
|
{
|
|
|
|
GNUNET_OS_process_kill (bankd,
|
|
|
|
SIGTERM);
|
|
|
|
GNUNET_OS_process_destroy (bankd);
|
|
|
|
}
|
2018-08-19 00:49:16 +02:00
|
|
|
}
|
2018-08-10 13:09:12 +02:00
|
|
|
GNUNET_OS_process_wait (exchanged);
|
|
|
|
GNUNET_OS_process_destroy (exchanged);
|
2019-03-13 04:16:22 +01:00
|
|
|
if (NULL != wirewatch)
|
2019-06-03 10:44:57 +02:00
|
|
|
{
|
2019-03-13 04:16:22 +01:00
|
|
|
GNUNET_OS_process_kill (wirewatch,
|
|
|
|
SIGTERM);
|
|
|
|
GNUNET_OS_process_wait (wirewatch);
|
|
|
|
GNUNET_OS_process_destroy (wirewatch);
|
|
|
|
}
|
2020-03-19 16:14:01 +01:00
|
|
|
if (NULL != auditord)
|
|
|
|
{
|
|
|
|
GNUNET_OS_process_kill (auditord,
|
|
|
|
SIGTERM);
|
|
|
|
GNUNET_OS_process_wait (auditord);
|
|
|
|
GNUNET_OS_process_destroy (auditord);
|
|
|
|
}
|
2018-08-09 19:47:23 +02:00
|
|
|
return 77;
|
|
|
|
}
|
2018-08-19 00:49:16 +02:00
|
|
|
if ( (MODE_CLIENT == mode) || (MODE_BOTH == mode) )
|
2018-08-07 22:10:38 +02:00
|
|
|
{
|
2020-03-20 02:36:50 +01:00
|
|
|
if (-1 != fakebank)
|
|
|
|
sleep (1); /* make sure fakebank process is ready before continuing */
|
2018-08-19 00:49:16 +02:00
|
|
|
|
|
|
|
start_time = GNUNET_TIME_absolute_get ();
|
|
|
|
result = GNUNET_OK;
|
2019-03-13 17:53:38 +01:00
|
|
|
|
2020-03-20 02:36:50 +01:00
|
|
|
if (1 == howmany_clients)
|
|
|
|
{
|
|
|
|
result = TALER_TESTING_setup (main_cb,
|
|
|
|
main_cb_cls,
|
|
|
|
cfg,
|
|
|
|
exchanged,
|
|
|
|
GNUNET_YES);
|
|
|
|
print_stats ();
|
2018-08-07 22:10:38 +02:00
|
|
|
}
|
2020-03-20 02:36:50 +01:00
|
|
|
else
|
2018-08-07 22:10:38 +02:00
|
|
|
{
|
2020-03-20 02:36:50 +01:00
|
|
|
for (unsigned int i = 0; i<howmany_clients; i++)
|
|
|
|
{
|
|
|
|
if (0 == (cpids[i] = fork ()))
|
|
|
|
{
|
|
|
|
/* I am the child, do the work! */
|
|
|
|
GNUNET_log_setup ("benchmark-worker",
|
|
|
|
NULL == loglev ? "INFO" : loglev,
|
|
|
|
logfile);
|
|
|
|
|
|
|
|
result = TALER_TESTING_setup (main_cb,
|
|
|
|
main_cb_cls,
|
|
|
|
cfg,
|
|
|
|
exchanged,
|
|
|
|
GNUNET_YES);
|
|
|
|
print_stats ();
|
|
|
|
if (GNUNET_OK != result)
|
|
|
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
|
|
|
"Failure in child process test suite!\n");
|
|
|
|
if (GNUNET_OK == result)
|
|
|
|
exit (0);
|
|
|
|
else
|
|
|
|
exit (1);
|
|
|
|
}
|
|
|
|
if (-1 == cpids[i])
|
|
|
|
{
|
|
|
|
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR,
|
|
|
|
"fork");
|
|
|
|
howmany_clients = i;
|
|
|
|
result = GNUNET_SYSERR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fork() success, continue starting more processes! */
|
|
|
|
}
|
|
|
|
/* collect all children */
|
|
|
|
for (unsigned int i = 0; i<howmany_clients; i++)
|
2018-08-19 00:49:16 +02:00
|
|
|
{
|
2020-03-20 02:36:50 +01:00
|
|
|
waitpid (cpids[i],
|
|
|
|
&wstatus,
|
|
|
|
0);
|
|
|
|
if ( (! WIFEXITED (wstatus)) ||
|
|
|
|
(0 != WEXITSTATUS (wstatus)) )
|
|
|
|
{
|
|
|
|
GNUNET_break (0);
|
|
|
|
result = GNUNET_SYSERR;
|
|
|
|
}
|
2018-08-19 00:49:16 +02:00
|
|
|
}
|
2018-08-07 22:10:38 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-19 00:49:16 +02:00
|
|
|
|
|
|
|
/* Wait for our master to die or to tell us to die */
|
|
|
|
if (MODE_EXCHANGE == mode)
|
2019-06-03 10:45:45 +02:00
|
|
|
(void) getchar ();
|
2018-08-19 00:49:16 +02:00
|
|
|
|
2020-01-19 15:36:43 +01:00
|
|
|
if ( (GNUNET_YES == linger) &&
|
|
|
|
( ((mode == MODE_BOTH) ||
|
|
|
|
(mode == MODE_CLIENT) ) ) )
|
2018-08-23 22:47:50 +02:00
|
|
|
{
|
2019-08-25 16:18:24 +02:00
|
|
|
printf ("press ENTER to stop\n");
|
2019-06-03 10:45:45 +02:00
|
|
|
(void) getchar ();
|
2018-08-23 22:47:50 +02:00
|
|
|
}
|
|
|
|
|
2018-08-19 00:49:16 +02:00
|
|
|
if (MODE_CLIENT == mode)
|
|
|
|
{
|
2019-05-01 20:52:43 +02:00
|
|
|
char c = 'q';
|
|
|
|
|
2018-08-19 00:49:16 +02:00
|
|
|
GNUNET_assert (NULL != exchange_slave);
|
2019-05-01 20:52:43 +02:00
|
|
|
|
|
|
|
/* Write a character to the pipe to end the exchange slave.
|
|
|
|
* We can't send a signal here, as it would just kill SSH and
|
|
|
|
* not necessarily the process on the other machine. */
|
|
|
|
GNUNET_DISK_file_write (GNUNET_DISK_pipe_handle
|
2019-08-25 16:18:24 +02:00
|
|
|
(exchange_slave_pipe, GNUNET_DISK_PIPE_END_WRITE),
|
2019-05-01 20:52:43 +02:00
|
|
|
&c, sizeof (c));
|
|
|
|
|
2019-05-01 19:44:00 +02:00
|
|
|
GNUNET_break (GNUNET_OK ==
|
|
|
|
GNUNET_OS_process_wait (exchange_slave));
|
2018-08-19 00:49:16 +02:00
|
|
|
GNUNET_OS_process_destroy (exchange_slave);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (MODE_EXCHANGE == mode) || (MODE_BOTH == mode) )
|
2018-08-07 22:10:38 +02:00
|
|
|
{
|
2018-08-19 00:49:16 +02:00
|
|
|
GNUNET_assert (NULL != wirewatch);
|
|
|
|
GNUNET_assert (NULL != exchanged);
|
2020-03-19 16:14:01 +01:00
|
|
|
GNUNET_assert (NULL != auditord);
|
2018-08-19 00:49:16 +02:00
|
|
|
/* stop wirewatch */
|
|
|
|
GNUNET_break (0 ==
|
|
|
|
GNUNET_OS_process_kill (wirewatch,
|
|
|
|
SIGTERM));
|
|
|
|
GNUNET_break (GNUNET_OK ==
|
|
|
|
GNUNET_OS_process_wait (wirewatch));
|
|
|
|
GNUNET_OS_process_destroy (wirewatch);
|
2020-03-19 16:14:01 +01:00
|
|
|
/* stop auditor */
|
|
|
|
GNUNET_break (0 ==
|
|
|
|
GNUNET_OS_process_kill (auditord,
|
|
|
|
SIGTERM));
|
|
|
|
GNUNET_break (GNUNET_OK ==
|
|
|
|
GNUNET_OS_process_wait (auditord));
|
|
|
|
GNUNET_OS_process_destroy (auditord);
|
2018-08-19 00:49:16 +02:00
|
|
|
/* stop exchange */
|
|
|
|
GNUNET_break (0 ==
|
|
|
|
GNUNET_OS_process_kill (exchanged,
|
|
|
|
SIGTERM));
|
|
|
|
GNUNET_break (GNUNET_OK ==
|
|
|
|
GNUNET_OS_process_wait (exchanged));
|
|
|
|
GNUNET_OS_process_destroy (exchanged);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (MODE_CLIENT == mode) || (MODE_BOTH == mode) )
|
|
|
|
{
|
|
|
|
/* stop fakebank */
|
2020-03-19 21:44:54 +01:00
|
|
|
if (-1 != fakebank)
|
|
|
|
{
|
|
|
|
kill (fakebank,
|
|
|
|
SIGTERM);
|
|
|
|
waitpid (fakebank,
|
|
|
|
&wstatus,
|
|
|
|
0);
|
|
|
|
if ( (! WIFEXITED (wstatus)) ||
|
|
|
|
(0 != WEXITSTATUS (wstatus)) )
|
|
|
|
{
|
|
|
|
GNUNET_break (0);
|
|
|
|
result = GNUNET_SYSERR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (NULL != bankd)
|
2018-08-09 19:47:23 +02:00
|
|
|
{
|
2020-03-19 21:44:54 +01:00
|
|
|
GNUNET_OS_process_kill (bankd,
|
|
|
|
SIGTERM);
|
|
|
|
GNUNET_OS_process_destroy (bankd);
|
2018-08-09 19:47:23 +02:00
|
|
|
}
|
|
|
|
}
|
2018-08-07 22:10:38 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-05-30 18:45:57 +02:00
|
|
|
/**
|
2018-07-25 13:26:47 +02:00
|
|
|
* The main function of the serve tool
|
2016-05-30 18:45:57 +02:00
|
|
|
*
|
2018-07-25 13:26:47 +02:00
|
|
|
* @param argc number of arguments from the command line
|
|
|
|
* @param argv command line arguments
|
|
|
|
* @return 0 ok, or `enum PaymentGeneratorError` on error
|
2016-05-30 18:45:57 +02:00
|
|
|
*/
|
2018-07-25 13:26:47 +02:00
|
|
|
int
|
|
|
|
main (int argc,
|
|
|
|
char *const *argv)
|
2016-05-30 18:45:57 +02:00
|
|
|
{
|
2018-07-25 13:26:47 +02:00
|
|
|
struct GNUNET_GETOPT_CommandLineOption options[] = {
|
2018-08-07 22:10:38 +02:00
|
|
|
GNUNET_GETOPT_option_mandatory
|
2019-08-25 16:18:24 +02:00
|
|
|
(GNUNET_GETOPT_option_cfgfile (&cfg_filename)),
|
2018-08-07 22:10:38 +02:00
|
|
|
GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION),
|
|
|
|
GNUNET_GETOPT_option_help ("Exchange benchmark"),
|
|
|
|
GNUNET_GETOPT_option_loglevel (&loglev),
|
|
|
|
GNUNET_GETOPT_option_uint ('n',
|
|
|
|
"coins-number",
|
|
|
|
"CN",
|
2018-08-11 02:48:49 +02:00
|
|
|
"How many coins we should instantiate per reserve",
|
2018-08-07 22:10:38 +02:00
|
|
|
&howmany_coins),
|
|
|
|
GNUNET_GETOPT_option_uint ('p',
|
|
|
|
"parallelism",
|
|
|
|
"NPROCS",
|
|
|
|
"How many client processes we should run",
|
|
|
|
&howmany_clients),
|
2018-08-11 02:48:49 +02:00
|
|
|
GNUNET_GETOPT_option_uint ('r',
|
|
|
|
"reserves",
|
|
|
|
"NRESERVES",
|
|
|
|
"How many reserves per client we should create",
|
|
|
|
&howmany_reserves),
|
2018-10-02 21:08:59 +02:00
|
|
|
GNUNET_GETOPT_option_uint ('R',
|
|
|
|
"refresh-rate",
|
|
|
|
"RATE",
|
|
|
|
"Probability of refresh per coin (0-100)",
|
|
|
|
&refresh_rate),
|
2018-08-19 00:49:16 +02:00
|
|
|
GNUNET_GETOPT_option_string ('m',
|
|
|
|
"mode",
|
|
|
|
"MODE",
|
|
|
|
"run as exchange, clients or both",
|
|
|
|
&mode_str),
|
2018-08-07 22:10:38 +02:00
|
|
|
GNUNET_GETOPT_option_string ('l',
|
|
|
|
"logfile",
|
|
|
|
"LF",
|
|
|
|
"will log to file LF",
|
|
|
|
&logfile),
|
2020-03-19 21:44:54 +01:00
|
|
|
GNUNET_GETOPT_option_flag ('f',
|
|
|
|
"fakebank",
|
|
|
|
"start a fakebank instead of the Python bank",
|
|
|
|
&use_fakebank),
|
2020-03-20 18:38:57 +01:00
|
|
|
GNUNET_GETOPT_option_flag ('F',
|
|
|
|
"reserves-first",
|
|
|
|
"should all reserves be created first, before starting normal operations",
|
|
|
|
&reserves_first),
|
2018-08-23 22:47:50 +02:00
|
|
|
GNUNET_GETOPT_option_flag ('K',
|
|
|
|
"linger",
|
|
|
|
"linger around until key press",
|
|
|
|
&linger),
|
2018-07-25 13:26:47 +02:00
|
|
|
GNUNET_GETOPT_OPTION_END
|
|
|
|
};
|
2018-07-27 11:58:54 +02:00
|
|
|
|
2018-08-07 22:10:38 +02:00
|
|
|
unsetenv ("XDG_DATA_HOME");
|
|
|
|
unsetenv ("XDG_CONFIG_HOME");
|
2018-09-21 15:15:30 +02:00
|
|
|
if (0 >=
|
2018-08-07 22:10:38 +02:00
|
|
|
(result = GNUNET_GETOPT_run ("taler-exchange-benchmark",
|
|
|
|
options,
|
|
|
|
argc,
|
|
|
|
argv)))
|
2016-06-03 02:28:57 +02:00
|
|
|
{
|
2020-07-05 16:56:41 +02:00
|
|
|
GNUNET_free (cfg_filename);
|
2021-01-07 10:40:01 +01:00
|
|
|
if (GNUNET_NO == result)
|
|
|
|
return 0;
|
2018-07-25 13:26:47 +02:00
|
|
|
return BAD_CLI_ARG;
|
2016-06-03 02:28:57 +02:00
|
|
|
}
|
2018-07-25 13:36:33 +02:00
|
|
|
GNUNET_log_setup ("taler-exchange-benchmark",
|
|
|
|
NULL == loglev ? "INFO" : loglev,
|
|
|
|
logfile);
|
2018-08-19 00:49:16 +02:00
|
|
|
if (NULL == mode_str)
|
|
|
|
mode = MODE_BOTH;
|
|
|
|
else if (0 == strcmp (mode_str, "exchange"))
|
|
|
|
mode = MODE_EXCHANGE;
|
|
|
|
else if (0 == strcmp (mode_str, "client"))
|
|
|
|
mode = MODE_CLIENT;
|
|
|
|
else if (0 == strcmp (mode_str, "both"))
|
|
|
|
mode = MODE_BOTH;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TALER_LOG_ERROR ("Unknown mode given: '%s'\n", mode_str);
|
2020-07-05 16:56:41 +02:00
|
|
|
GNUNET_free (cfg_filename);
|
2018-08-19 00:49:16 +02:00
|
|
|
return BAD_CONFIG_FILE;
|
|
|
|
}
|
2019-06-30 20:50:05 +02:00
|
|
|
if (NULL == cfg_filename)
|
2019-08-25 16:18:24 +02:00
|
|
|
cfg_filename = GNUNET_strdup (
|
|
|
|
GNUNET_OS_project_data_get ()->user_config_file);
|
2016-06-08 16:12:31 +02:00
|
|
|
cfg = GNUNET_CONFIGURATION_create ();
|
2018-08-07 22:10:38 +02:00
|
|
|
if (GNUNET_OK !=
|
|
|
|
GNUNET_CONFIGURATION_load (cfg,
|
|
|
|
cfg_filename))
|
2016-06-09 17:22:15 +02:00
|
|
|
{
|
2018-07-25 13:26:47 +02:00
|
|
|
TALER_LOG_ERROR ("Could not parse configuration\n");
|
2020-02-04 21:59:43 +01:00
|
|
|
GNUNET_free (cfg_filename);
|
2018-07-25 13:26:47 +02:00
|
|
|
return BAD_CONFIG_FILE;
|
2016-06-09 17:22:15 +02:00
|
|
|
}
|
2018-08-07 22:10:38 +02:00
|
|
|
if (GNUNET_OK !=
|
2020-03-15 20:08:38 +01:00
|
|
|
TALER_config_get_currency (cfg,
|
|
|
|
¤cy))
|
2016-06-15 15:09:57 +02:00
|
|
|
{
|
2020-02-04 21:59:43 +01:00
|
|
|
GNUNET_CONFIGURATION_destroy (cfg);
|
2020-03-14 16:24:44 +01:00
|
|
|
GNUNET_free (cfg_filename);
|
2020-02-04 21:59:43 +01:00
|
|
|
return BAD_CONFIG_FILE;
|
|
|
|
}
|
2018-08-19 13:08:05 +02:00
|
|
|
if (howmany_clients > 10240)
|
2018-08-07 22:10:38 +02:00
|
|
|
{
|
|
|
|
TALER_LOG_ERROR ("-p option value given is too large\n");
|
|
|
|
return BAD_CLI_ARG;
|
|
|
|
}
|
2020-01-18 19:16:33 +01:00
|
|
|
if (0 == howmany_clients)
|
|
|
|
{
|
|
|
|
TALER_LOG_ERROR ("-p option value must not be zero\n");
|
2020-03-14 16:24:44 +01:00
|
|
|
GNUNET_free (cfg_filename);
|
2020-01-18 19:16:33 +01:00
|
|
|
return BAD_CLI_ARG;
|
|
|
|
}
|
2020-01-12 01:03:08 +01:00
|
|
|
if (GNUNET_OK !=
|
2020-01-19 15:36:43 +01:00
|
|
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
|
|
|
"benchmark",
|
|
|
|
"USER_PAYTO_URI",
|
2020-01-19 17:03:19 +01:00
|
|
|
&user_payto_uri))
|
2020-01-11 15:19:56 +01:00
|
|
|
{
|
2020-01-12 01:03:08 +01:00
|
|
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
|
|
"benchmark",
|
2020-01-19 15:36:43 +01:00
|
|
|
"USER_PAYTO_URI");
|
2020-03-14 16:24:44 +01:00
|
|
|
GNUNET_free (cfg_filename);
|
2020-01-12 01:03:08 +01:00
|
|
|
return BAD_CONFIG_FILE;
|
2020-01-11 15:19:56 +01:00
|
|
|
}
|
2016-09-23 16:52:13 +02:00
|
|
|
|
2016-06-15 15:09:57 +02:00
|
|
|
{
|
2019-03-13 04:30:07 +01:00
|
|
|
const char *bank_details_section;
|
2018-07-27 14:47:02 +02:00
|
|
|
|
2020-01-13 00:27:48 +01:00
|
|
|
GNUNET_CONFIGURATION_iterate_sections (cfg,
|
|
|
|
&pick_exchange_account_cb,
|
|
|
|
&bank_details_section);
|
2019-03-13 04:11:35 +01:00
|
|
|
if (NULL == bank_details_section)
|
|
|
|
{
|
|
|
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
2020-01-19 15:36:43 +01:00
|
|
|
"Missing specification of bank account in configuration\n");
|
2020-03-14 16:24:44 +01:00
|
|
|
GNUNET_free (cfg_filename);
|
2019-03-13 04:11:35 +01:00
|
|
|
return BAD_CONFIG_FILE;
|
|
|
|
}
|
|
|
|
if (GNUNET_OK !=
|
2020-01-19 15:36:43 +01:00
|
|
|
TALER_BANK_auth_parse_cfg (cfg,
|
|
|
|
bank_details_section,
|
|
|
|
&exchange_bank_account))
|
2019-03-13 04:11:35 +01:00
|
|
|
{
|
2020-01-19 15:36:43 +01:00
|
|
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
|
|
|
"Configuration fails to provide exchange bank details in section `%s'\n",
|
|
|
|
bank_details_section);
|
2020-03-14 16:24:44 +01:00
|
|
|
GNUNET_free (cfg_filename);
|
2019-03-13 04:11:35 +01:00
|
|
|
return BAD_CONFIG_FILE;
|
|
|
|
}
|
2016-06-15 15:09:57 +02:00
|
|
|
}
|
2018-08-19 00:49:16 +02:00
|
|
|
if ( (MODE_EXCHANGE == mode) || (MODE_BOTH == mode) )
|
|
|
|
{
|
|
|
|
struct GNUNET_OS_Process *compute_wire_response;
|
|
|
|
|
2020-01-19 15:36:43 +01:00
|
|
|
compute_wire_response
|
2020-07-17 22:18:57 +02:00
|
|
|
= GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_ALL,
|
2020-01-19 15:36:43 +01:00
|
|
|
NULL, NULL, NULL,
|
|
|
|
"taler-exchange-wire",
|
|
|
|
"taler-exchange-wire",
|
|
|
|
"-c", cfg_filename,
|
|
|
|
NULL);
|
2018-08-19 00:49:16 +02:00
|
|
|
if (NULL == compute_wire_response)
|
|
|
|
{
|
|
|
|
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
2020-01-19 15:36:43 +01:00
|
|
|
"Failed to run `taler-exchange-wire`, is your PATH correct?\n");
|
2020-03-14 16:24:44 +01:00
|
|
|
GNUNET_free (cfg_filename);
|
|
|
|
return BAD_CONFIG_FILE;
|
2018-08-19 00:49:16 +02:00
|
|
|
}
|
|
|
|
GNUNET_OS_process_wait (compute_wire_response);
|
|
|
|
GNUNET_OS_process_destroy (compute_wire_response);
|
2020-03-19 21:44:54 +01:00
|
|
|
/* If we use the fakebank, we MUST reset the database as the fakebank
|
|
|
|
will have forgotten everything... */
|
2020-01-13 00:27:48 +01:00
|
|
|
GNUNET_assert (GNUNET_OK ==
|
|
|
|
TALER_TESTING_prepare_exchange (cfg_filename,
|
2020-03-19 21:44:54 +01:00
|
|
|
(GNUNET_YES == use_fakebank)
|
|
|
|
? GNUNET_YES
|
|
|
|
: GNUNET_NO,
|
2020-01-13 00:27:48 +01:00
|
|
|
&ec));
|
2018-08-19 00:49:16 +02:00
|
|
|
}
|
|
|
|
else
|
2018-07-25 16:18:49 +02:00
|
|
|
{
|
2019-03-13 04:30:07 +01:00
|
|
|
if (GNUNET_OK !=
|
2018-08-19 00:49:16 +02:00
|
|
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
|
|
|
"exchange",
|
|
|
|
"BASE_URL",
|
2020-01-13 00:27:48 +01:00
|
|
|
&ec.exchange_url))
|
2018-08-19 00:49:16 +02:00
|
|
|
{
|
|
|
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
|
|
"exchange",
|
|
|
|
"base_url");
|
|
|
|
GNUNET_CONFIGURATION_destroy (cfg);
|
2020-03-14 16:24:44 +01:00
|
|
|
GNUNET_free (cfg_filename);
|
2018-08-19 00:49:16 +02:00
|
|
|
return BAD_CONFIG_FILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GNUNET_OK !=
|
|
|
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
|
|
|
"benchmark-remote-exchange",
|
|
|
|
"host",
|
|
|
|
&remote_host))
|
|
|
|
{
|
|
|
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
|
|
"benchmark-remote-exchange",
|
|
|
|
"host");
|
|
|
|
GNUNET_CONFIGURATION_destroy (cfg);
|
2020-03-14 16:24:44 +01:00
|
|
|
GNUNET_free (cfg_filename);
|
2018-08-19 00:49:16 +02:00
|
|
|
return BAD_CONFIG_FILE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (GNUNET_OK !=
|
|
|
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
|
|
|
"benchmark-remote-exchange",
|
|
|
|
"dir",
|
|
|
|
&remote_dir))
|
|
|
|
{
|
|
|
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
|
|
|
"benchmark-remote-exchange",
|
|
|
|
"dir");
|
|
|
|
GNUNET_CONFIGURATION_destroy (cfg);
|
2020-03-14 16:24:44 +01:00
|
|
|
GNUNET_free (cfg_filename);
|
2018-08-19 00:49:16 +02:00
|
|
|
return BAD_CONFIG_FILE;
|
|
|
|
}
|
2018-07-25 16:18:49 +02:00
|
|
|
}
|
2018-08-19 00:49:16 +02:00
|
|
|
|
2018-08-07 22:10:38 +02:00
|
|
|
result = parallel_benchmark (&run,
|
|
|
|
NULL,
|
2020-01-13 00:27:48 +01:00
|
|
|
cfg_filename);
|
2020-02-04 21:59:43 +01:00
|
|
|
GNUNET_CONFIGURATION_destroy (cfg);
|
2020-03-14 16:24:44 +01:00
|
|
|
GNUNET_free (cfg_filename);
|
2019-05-02 23:45:31 +02:00
|
|
|
|
|
|
|
/* If we're the exchange worker, we're done now. No need to print results */
|
|
|
|
if (MODE_EXCHANGE == mode)
|
2020-03-14 16:24:44 +01:00
|
|
|
{
|
2019-05-02 23:45:31 +02:00
|
|
|
return (GNUNET_OK == result) ? 0 : result;
|
2020-03-14 16:24:44 +01:00
|
|
|
}
|
2018-07-25 13:26:47 +02:00
|
|
|
duration = GNUNET_TIME_absolute_get_duration (start_time);
|
2018-08-09 21:10:56 +02:00
|
|
|
if (GNUNET_OK == result)
|
|
|
|
{
|
2018-10-02 17:26:42 +02:00
|
|
|
struct rusage usage;
|
2019-08-25 16:18:24 +02:00
|
|
|
GNUNET_assert (0 == getrusage (RUSAGE_CHILDREN, &usage));
|
2018-08-09 21:10:56 +02:00
|
|
|
fprintf (stdout,
|
2018-08-11 02:48:49 +02:00
|
|
|
"Executed (Withdraw=%u, Deposit=%u, Refresh~=%5.2f) * Reserve=%u * Parallel=%u, operations in %s\n",
|
2018-08-09 21:10:56 +02:00
|
|
|
howmany_coins,
|
|
|
|
howmany_coins,
|
2018-10-02 21:08:59 +02:00
|
|
|
(float) howmany_coins * (refresh_rate / 100.0),
|
2018-08-11 02:48:49 +02:00
|
|
|
howmany_reserves,
|
2018-08-09 21:10:56 +02:00
|
|
|
howmany_clients,
|
|
|
|
GNUNET_STRINGS_relative_time_to_string
|
2019-08-25 16:18:24 +02:00
|
|
|
(duration,
|
|
|
|
GNUNET_NO));
|
2018-08-09 21:10:56 +02:00
|
|
|
fprintf (stdout,
|
|
|
|
"(approximately %s/coin)\n",
|
|
|
|
GNUNET_STRINGS_relative_time_to_string
|
2019-08-25 16:18:24 +02:00
|
|
|
(GNUNET_TIME_relative_divide (duration,
|
|
|
|
(unsigned long long) howmany_coins
|
|
|
|
* howmany_reserves
|
|
|
|
* howmany_clients),
|
|
|
|
GNUNET_YES));
|
2018-08-11 02:48:49 +02:00
|
|
|
fprintf (stdout,
|
|
|
|
"RAW: %04u %04u %04u %16llu\n",
|
|
|
|
howmany_coins,
|
|
|
|
howmany_reserves,
|
|
|
|
howmany_clients,
|
|
|
|
(unsigned long long) duration.rel_value_us);
|
2018-10-02 17:26:42 +02:00
|
|
|
fprintf (stdout, "cpu time: sys %llu user %llu\n", \
|
2019-08-25 16:18:24 +02:00
|
|
|
(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));
|
2018-08-09 21:10:56 +02:00
|
|
|
}
|
2020-01-19 22:23:57 +01:00
|
|
|
for (unsigned int i = 0; i<label_off; i++)
|
|
|
|
GNUNET_free (labels[i]);
|
|
|
|
GNUNET_array_grow (labels,
|
|
|
|
label_len,
|
|
|
|
0);
|
2018-07-25 13:26:47 +02:00
|
|
|
return (GNUNET_OK == result) ? 0 : result;
|
2016-05-30 15:08:12 +02:00
|
|
|
}
|