commenting and reorganizing
This commit is contained in:
parent
1e3a45e0cd
commit
cf798e77fe
@ -22,6 +22,19 @@
|
||||
#include "perf_taler_mintdb_interpreter.h"
|
||||
#include "perf_taler_mintdb_values.h"
|
||||
|
||||
|
||||
#define PERF_TALER_MINTDB_NB_DENOMINATION_INIT 10
|
||||
#define PERF_TALER_MINTDB_NB_DENOMINATION_SAVE 10
|
||||
|
||||
#define PERF_TALER_MINTDB_NB_RESERVE_INIT 100
|
||||
#define PERF_TALER_MINTDB_NB_RESERVE_SAVE 10
|
||||
|
||||
#define PERF_TALER_MINTDB_NB_DEPOSIT_INIT 100
|
||||
#define PERF_TALER_MINTDB_NB_DEPOSIT_SAVE 10
|
||||
|
||||
#define PERF_TALER_MINTDB_NB_WITHDRAW_INIT 100
|
||||
#define PERF_TALER_MINTDB_NB_WITHDRAW_SAVE 10
|
||||
|
||||
/**
|
||||
* Runs the performances tests for the mint database
|
||||
* and logs the results using Gauger
|
||||
@ -29,9 +42,8 @@
|
||||
int
|
||||
main (int argc, char ** argv)
|
||||
{
|
||||
struct TALER_MINTDB_Plugin *plugin;
|
||||
struct GNUNET_CONFIGURATION_Handle *config;
|
||||
struct PERF_TALER_MINTDB_Cmd test[] =
|
||||
int ret;
|
||||
struct PERF_TALER_MINTDB_Cmd benchmark[] =
|
||||
{
|
||||
// Denomination used to create coins
|
||||
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("00 - Start of interpreter"),
|
||||
@ -104,23 +116,10 @@ main (int argc, char ** argv)
|
||||
PERF_TALER_MINTDB_INIT_CMD_END ("end"),
|
||||
};
|
||||
|
||||
GNUNET_log_setup ("perf-taler-mintdb",
|
||||
"INFO",
|
||||
NULL);
|
||||
config = GNUNET_CONFIGURATION_create ();
|
||||
GNUNET_CONFIGURATION_load (config, "./test-mint-db-postgres.conf");
|
||||
GNUNET_assert (NULL !=
|
||||
(plugin = TALER_MINTDB_plugin_load (config)));
|
||||
plugin->create_tables (plugin->cls, GNUNET_YES);
|
||||
PERF_TALER_MINTDB_interpret (plugin, test);
|
||||
/* Drop tables */
|
||||
{
|
||||
struct TALER_MINTDB_Session *session;
|
||||
ret = PERF_TALER_MINTDB_run_benchmark ("perf-taler-mintdb",
|
||||
"./test-mint-db-postgres.conf",
|
||||
NULL,
|
||||
benchmark);
|
||||
|
||||
session = plugin->get_session (plugin->cls, GNUNET_YES);
|
||||
plugin->drop_temporary (plugin->cls, session);
|
||||
}
|
||||
TALER_MINTDB_plugin_unload (plugin);
|
||||
GNUNET_CONFIGURATION_destroy (config);
|
||||
return 0;
|
||||
}
|
||||
|
@ -79,11 +79,6 @@ data_free (struct PERF_TALER_MINTDB_Data *data)
|
||||
data->data.dki = NULL;
|
||||
return;
|
||||
|
||||
case PERF_TALER_MINTDB_COIN_INFO:
|
||||
PERF_TALER_MINTDB_coin_public_info_free (data->data.cpi);
|
||||
data->data.cpi = NULL;
|
||||
return;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@ -91,7 +86,10 @@ data_free (struct PERF_TALER_MINTDB_Data *data)
|
||||
|
||||
|
||||
/**
|
||||
* Copies @a data into @a copy
|
||||
*
|
||||
* @param data the data to be copied
|
||||
* @param[out] copy the copy made
|
||||
*/
|
||||
static void
|
||||
data_copy (const struct PERF_TALER_MINTDB_Data *data, struct PERF_TALER_MINTDB_Data *copy)
|
||||
@ -128,6 +126,7 @@ data_copy (const struct PERF_TALER_MINTDB_Data *data, struct PERF_TALER_MINTDB_D
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finds the first command in cmd with the name search
|
||||
*
|
||||
@ -148,6 +147,8 @@ cmd_find (const struct PERF_TALER_MINTDB_Cmd *cmd, const char *search)
|
||||
|
||||
/**
|
||||
* Initialization of a command array
|
||||
*
|
||||
* @param cmd the comand array initialized
|
||||
*/
|
||||
static int
|
||||
cmd_init (struct PERF_TALER_MINTDB_Cmd cmd[])
|
||||
@ -238,7 +239,8 @@ cmd_clean (struct PERF_TALER_MINTDB_Cmd cmd[])
|
||||
|
||||
|
||||
/**
|
||||
* Handles the command END_LOOP for the interpreter
|
||||
* Handles the command #PERF_TALER_MINTDB_CMD_END_LOOP for the interpreter
|
||||
* Cleans the memory at the end of the loop
|
||||
*/
|
||||
static void
|
||||
interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||
@ -273,6 +275,8 @@ interpret_end_loop (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||
|
||||
|
||||
/**
|
||||
* Part of the interpreter specific to
|
||||
* #PERF_TALER_MINTDB_CMD_SAVE_ARRAY
|
||||
* Saves the data exposed by another command into
|
||||
* an array in the command specific struct.
|
||||
*/
|
||||
@ -289,7 +293,7 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||
GNUNET_assert (GNUNET_SYSERR !=
|
||||
(loop_index = cmd_find (state->cmd,
|
||||
cmd->details.save_array.label_loop)));
|
||||
loop_ref = &state->cmd[save_index];
|
||||
loop_ref = &state->cmd[loop_index];
|
||||
GNUNET_assert (GNUNET_SYSERR !=
|
||||
(save_index = cmd_find (state->cmd,
|
||||
cmd->details.save_array.label_save)));
|
||||
@ -303,37 +307,37 @@ interpret_save_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||
/* The probobility distribution of the saved items will be a little biased
|
||||
against the few last items but it should not be a big problem. */
|
||||
selection_chance = loop_ref->details.loop.max_iterations /
|
||||
state->cmd[state->i].details.save_array.nb_saved;
|
||||
cmd->details.save_array.nb_saved;
|
||||
/*
|
||||
* If the remaining space is equal to the remaining number of
|
||||
* iterations, the item is automaticly saved.
|
||||
*
|
||||
* Else it is saved only if the random numbre generated is 0
|
||||
*/
|
||||
if ( (0 < (state->cmd[state->i].details.save_array.nb_saved -
|
||||
state->cmd[state->i].details.save_array.index) ) &&
|
||||
( ((state->cmd[loop_index].details.loop.max_iterations -
|
||||
state->cmd[loop_index].details.loop.curr_iteration) ==
|
||||
(state->cmd[state->i].details.save_array.nb_saved -
|
||||
state->cmd[state->i].details.save_array.index)) ||
|
||||
if ( (0 < (cmd->details.save_array.nb_saved -
|
||||
cmd->details.save_array.index) ) &&
|
||||
( ((loop_ref->details.loop.max_iterations -
|
||||
loop_ref->details.loop.curr_iteration) ==
|
||||
(cmd->details.save_array.nb_saved -
|
||||
cmd->details.save_array.index)) ||
|
||||
(0 == GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
|
||||
selection_chance)) ) )
|
||||
{
|
||||
struct PERF_TALER_MINTDB_Data *save_location;
|
||||
struct PERF_TALER_MINTDB_Data *item_saved;
|
||||
|
||||
save_location = &state->cmd[state->i].details.save_array
|
||||
.data_saved[state->cmd[state->i].details.save_array.index];
|
||||
item_saved = &state->cmd[save_index].exposed;
|
||||
save_location = &cmd->details.save_array.data_saved[cmd->details.save_array.index];
|
||||
item_saved = &save_ref->exposed;
|
||||
data_copy (item_saved, save_location);
|
||||
state->cmd[state->i].details.save_array.index++;
|
||||
cmd->details.save_array.index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run when the current command is LOAD_ARRAY
|
||||
* Get data from a SAVE_ARRAY and exposes a copy
|
||||
* Part of the interpreter specific to
|
||||
* #PERF_TALER_MINTDB_CMD_LOAD_ARRAY
|
||||
* Gets data from a #PERF_TALER_MINTDB_CMD_SAVE_ARRAY and exposes a copy
|
||||
*/
|
||||
static void
|
||||
interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||
@ -355,7 +359,7 @@ interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||
{
|
||||
int i, quotient;
|
||||
|
||||
/* in case the iteration number is higher than the amount saved,
|
||||
/* In case the iteration number is higher than the amount saved,
|
||||
* the number is run several times in the permutation array */
|
||||
quotient = loop_iter / state->cmd[save_index].details.save_array.nb_saved;
|
||||
loop_iter = loop_iter % state->cmd[save_index].details.save_array.nb_saved;
|
||||
@ -371,8 +375,9 @@ interpret_load_array (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||
|
||||
|
||||
/**
|
||||
* Main interpreter loop.
|
||||
* Iterate over the commands, acting accordingly at each step
|
||||
*
|
||||
* @param state the current state of the interpreter
|
||||
*/
|
||||
static int
|
||||
interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||
@ -615,6 +620,9 @@ interpret (struct PERF_TALER_MINTDB_interpreter_state *state)
|
||||
/**
|
||||
* Runs the commands given in @a cmd, working with
|
||||
* the database referenced by @a db_plugin
|
||||
*
|
||||
* @param db_plugin the connection to the database
|
||||
* @param cmd the commands to run
|
||||
*/
|
||||
int
|
||||
PERF_TALER_MINTDB_interpret (struct TALER_MINTDB_Plugin *db_plugin,
|
||||
@ -623,14 +631,180 @@ PERF_TALER_MINTDB_interpret (struct TALER_MINTDB_Plugin *db_plugin,
|
||||
struct PERF_TALER_MINTDB_interpreter_state state =
|
||||
{.i = 0, .cmd = cmd, .plugin = db_plugin};
|
||||
|
||||
// Initializing commands
|
||||
cmd_init (state.cmd);
|
||||
// Running the interpreter
|
||||
GNUNET_assert (NULL !=
|
||||
(state.session = db_plugin->get_session (db_plugin->cls,
|
||||
GNUNET_YES)));
|
||||
interpret (&state);
|
||||
// Cleaning the memory
|
||||
cmd_clean (cmd);
|
||||
return GNUNET_YES;
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param benchmark_name the name of the benchmark, displayed in the logs
|
||||
* @param configuration_file path to the taler configuration file to use
|
||||
* @param init the commands to use for the database initialisation,
|
||||
* if #NULL the standard initialization is used
|
||||
* @param benchmark the commands for the benchmark
|
||||
* @return GNUNET_OK upon success; GNUNET_SYSERR upon failure
|
||||
*/
|
||||
int
|
||||
PERF_TALER_MINTDB_run_benchmark (const char *benchmark_name,
|
||||
const char *configuration_file,
|
||||
struct PERF_TALER_MINTDB_Cmd *init,
|
||||
struct PERF_TALER_MINTDB_Cmd *benchmark)
|
||||
{
|
||||
struct TALER_MINTDB_Plugin *plugin;
|
||||
struct GNUNET_CONFIGURATION_Handle *config;
|
||||
int ret = 0;
|
||||
struct PERF_TALER_MINTDB_Cmd init_def[] =
|
||||
{
|
||||
// Denomination used to create coins
|
||||
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("00 - Start of interpreter"),
|
||||
|
||||
PERF_TALER_MINTDB_INIT_CMD_LOOP ("01 - denomination loop",
|
||||
PERF_TALER_MINTDB_NB_DENOMINATION_INIT),
|
||||
PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("01 - start transaction"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION ("01 - denomination"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("01 - commit transaction"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("01 - save denomination",
|
||||
"01 - denomination loop",
|
||||
"01 - denomination",
|
||||
PERF_TALER_MINTDB_NB_DENOMINATION_SAVE),
|
||||
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("01 - denomination loop end",
|
||||
"01 - denomination loop"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("01 - init denomination complete"),
|
||||
// End of initialization
|
||||
// Reserve initialization
|
||||
PERF_TALER_MINTDB_INIT_CMD_LOOP ("02 - init reserve loop",
|
||||
PERF_TALER_MINTDB_NB_RESERVE_INIT),
|
||||
PERF_TALER_MINTDB_INIT_CMD_INSERT_RESERVE ("02 - reserve"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("02 - save reserve",
|
||||
"02 - init reserve loop",
|
||||
"02 - reserve",
|
||||
PERF_TALER_MINTDB_NB_RESERVE_SAVE),
|
||||
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("02 - init reserve end loop",
|
||||
"02 - init reserve loop"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("02 - reserve init complete"),
|
||||
// End reserve init
|
||||
// Withdrawal initialization
|
||||
PERF_TALER_MINTDB_INIT_CMD_LOOP ("03 - init withdraw loop",
|
||||
PERF_TALER_MINTDB_NB_WITHDRAW_INIT),
|
||||
PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("03 - start transaction"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("03 - denomination load",
|
||||
"03 - init withdraw loop",
|
||||
"01 - save denomination"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("03 - reserve load",
|
||||
"03 - init withdraw loop",
|
||||
"02 - save reserve"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_INSERT_WITHDRAW ("03 - withdraw",
|
||||
"03 - denomination load",
|
||||
"03 - reserve load"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("03 - commit transaction"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("03 - blindcoin array",
|
||||
"03 - init withdraw loop",
|
||||
"03 - withdraw",
|
||||
PERF_TALER_MINTDB_NB_WITHDRAW_SAVE),
|
||||
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("03 - withdraw init end loop",
|
||||
"03 - init withdraw loop"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("03 - withdraw init complete"),
|
||||
//End of withdrawal initialization
|
||||
//Deposit initialization
|
||||
PERF_TALER_MINTDB_INIT_CMD_LOOP ("04 - deposit init loop",
|
||||
PERF_TALER_MINTDB_NB_DEPOSIT_INIT),
|
||||
PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION ("04 - start transaction"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY ("04 - denomination load",
|
||||
"04 - deposit init loop",
|
||||
"01 - save denomination"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT ("04 - deposit",
|
||||
"04 - denomination load"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION ("04 - commit transaction"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY ("04 - deposit array",
|
||||
"04 - deposit init loop",
|
||||
"04 - deposit",
|
||||
PERF_TALER_MINTDB_NB_DEPOSIT_SAVE),
|
||||
PERF_TALER_MINTDB_INIT_CMD_END_LOOP ("04 - deposit init loop end",
|
||||
"04 - deposit init loop"),
|
||||
PERF_TALER_MINTDB_INIT_CMD_DEBUG ("04 - deposit init complete"),
|
||||
// End of deposit initialization
|
||||
PERF_TALER_MINTDB_INIT_CMD_END ("end")
|
||||
};
|
||||
|
||||
GNUNET_log_setup (benchmark_name,
|
||||
"INFO",
|
||||
NULL);
|
||||
config = GNUNET_CONFIGURATION_create ();
|
||||
|
||||
ret = GNUNET_CONFIGURATION_load (config,
|
||||
configuration_file);
|
||||
if (GNUNET_OK != ret)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Error parsing configuration file");
|
||||
return GNUNET_SYSERR;
|
||||
}
|
||||
plugin = TALER_MINTDB_plugin_load (config);
|
||||
if (NULL == plugin)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Error connectiong to the database");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
ret = plugin->create_tables (plugin->cls,
|
||||
GNUNET_YES);
|
||||
if (GNUNET_OK != ret)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Error while creating the database architecture");
|
||||
return ret;
|
||||
}
|
||||
/*
|
||||
* Running the initialization
|
||||
*/
|
||||
if (NULL == init)
|
||||
{
|
||||
init = init_def;
|
||||
}
|
||||
ret = PERF_TALER_MINTDB_interpret (plugin,
|
||||
init);
|
||||
if (GNUNET_OK != ret)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Error during database initialization");
|
||||
return ret;
|
||||
}
|
||||
/*
|
||||
* Running the benchmark
|
||||
*/
|
||||
ret = PERF_TALER_MINTDB_interpret (plugin,
|
||||
benchmark);
|
||||
if (GNUNET_OK != ret)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Error during database initialization");
|
||||
return ret;
|
||||
}
|
||||
/* Drop tables */
|
||||
{
|
||||
struct TALER_MINTDB_Session *session;
|
||||
|
||||
session = plugin->get_session (plugin->cls,
|
||||
GNUNET_YES);
|
||||
ret = plugin->drop_temporary (plugin->cls,
|
||||
session);
|
||||
if (GNUNET_OK != ret)
|
||||
{
|
||||
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
|
||||
"Error removing cleaning the database");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
TALER_MINTDB_plugin_unload (plugin);
|
||||
GNUNET_CONFIGURATION_destroy (config);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -25,9 +25,24 @@
|
||||
#include <sys/time.h>
|
||||
#include "taler_mintdb_plugin.h"
|
||||
|
||||
|
||||
#define PERF_TALER_MINTDB_NB_DENOMINATION_INIT 10
|
||||
#define PERF_TALER_MINTDB_NB_DENOMINATION_SAVE 10
|
||||
|
||||
#define PERF_TALER_MINTDB_NB_RESERVE_INIT 100
|
||||
#define PERF_TALER_MINTDB_NB_RESERVE_SAVE 10
|
||||
|
||||
#define PERF_TALER_MINTDB_NB_DEPOSIT_INIT 100
|
||||
#define PERF_TALER_MINTDB_NB_DEPOSIT_SAVE 10
|
||||
|
||||
#define PERF_TALER_MINTDB_NB_WITHDRAW_INIT 100
|
||||
#define PERF_TALER_MINTDB_NB_WITHDRAW_SAVE 10
|
||||
|
||||
|
||||
/**
|
||||
* Marks the end of the command chain
|
||||
* @param _label
|
||||
*
|
||||
* @param _label The label of the command
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_END(_label) \
|
||||
{ \
|
||||
@ -39,6 +54,9 @@
|
||||
|
||||
/**
|
||||
* Prints @ _label to stdout
|
||||
*
|
||||
* @param _label The label of the command,
|
||||
* will be logged each time the command runs
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_DEBUG(_label) \
|
||||
{ \
|
||||
@ -49,7 +67,8 @@
|
||||
|
||||
/**
|
||||
* The begining of a loop
|
||||
* @param _label the name of the loop
|
||||
*
|
||||
* @param _label the label of the loop
|
||||
* @param _iter the number of iterations of the loop
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_LOOP(_label, _iter) \
|
||||
@ -64,6 +83,9 @@
|
||||
|
||||
/**
|
||||
* Marks the end of the loop @_label_loop
|
||||
*
|
||||
* @param _label the label of the command
|
||||
* @param _label_loop the label of the loop closed by this command
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_END_LOOP(_label, _label_loop) \
|
||||
{\
|
||||
@ -75,6 +97,8 @@
|
||||
|
||||
/**
|
||||
* Saves the time of execution to use for logging with Gauger
|
||||
*
|
||||
* @param _label the label of the command
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_GET_TIME(_label) \
|
||||
{ \
|
||||
@ -107,6 +131,8 @@
|
||||
|
||||
/**
|
||||
* Initiate a database transaction
|
||||
*
|
||||
* @param _label the label of the command
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_START_TRANSACTION(_label) \
|
||||
{ \
|
||||
@ -117,6 +143,8 @@
|
||||
|
||||
/**
|
||||
* Commits a database transaction
|
||||
*
|
||||
* @param _label the label of the command
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_COMMIT_TRANSACTION(_label) \
|
||||
{ \
|
||||
@ -126,8 +154,23 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts @a _nb_saved items of type @a _save_type
|
||||
* from the command @a _label_save during the loop @a _label_loop
|
||||
* Abort the current transaction
|
||||
*
|
||||
* @param _label the label of the command
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_ABORT_TRANSACTION(_label) \
|
||||
{ \
|
||||
.command = PERF_TALER_MINTDB_CMD_ABORT_TRANSACTION, \
|
||||
.label = _label,
|
||||
|
||||
/**
|
||||
* Saves randomly selected items from @a _label_save
|
||||
* Saved items can latter be access using #PERF_TALER_MINTDB_CMD_LOAD_ARRAY
|
||||
*
|
||||
* @param _label the label of the command, used by other commands to reference it
|
||||
* @param _label_loop the label of the loop the array iterates over
|
||||
* @param _label_save the label of the command which outout is saved by this command
|
||||
* @param _nb_saved the total number of tiems to be saved
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_SAVE_ARRAY(_label, _label_loop, _label_save, _nb_saved) \
|
||||
{ \
|
||||
@ -142,8 +185,12 @@
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads @a _nb_saved previously sampled data of type @a _saved_type
|
||||
* from @a _label_save during the loop @a _label_loop
|
||||
* Loads data from a #PERF_TALER_MINTDB_CMD_SAVE_ARRAY to allow other
|
||||
* commands to access it
|
||||
*
|
||||
* @param _label the label of this command, referenced by commands to access it's outpout
|
||||
* @param _label_loop the label of the loop to iterate over
|
||||
* @param _label_save the label of the #PERF_TALER_MINTDB_CMD_SAVE_ARRAY providing data
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_LOAD_ARRAY(_label, _label_loop, _label_save) \
|
||||
{ \
|
||||
@ -158,6 +205,8 @@
|
||||
|
||||
/**
|
||||
* Inserts informations about a denomination key in the database
|
||||
*
|
||||
* @param _label the label of this command
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DENOMINATION(_label) \
|
||||
{ \
|
||||
@ -168,6 +217,9 @@
|
||||
|
||||
/**
|
||||
* Polls the database about informations regarding a specific denomination key
|
||||
*
|
||||
* @param _label the label of this command
|
||||
* @param _label_source the label of the command prividing information about the denomination key
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_GET_DENOMINATION(_label, _label_source) \
|
||||
{ \
|
||||
@ -179,6 +231,8 @@
|
||||
|
||||
/**
|
||||
* Creates a new reserve in the database
|
||||
*
|
||||
* @param _label the name of this command
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_INSERT_RESERVE(_label) \
|
||||
{ \
|
||||
@ -190,6 +244,8 @@
|
||||
|
||||
/**
|
||||
* Polls the database for a secific reserve's details
|
||||
*
|
||||
* @param _label the label of this command
|
||||
* @param _label_source Source for the reserve to poll
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_GET_RESERVE(_label, _label_source) \
|
||||
@ -203,6 +259,8 @@
|
||||
|
||||
/**
|
||||
* Insert a deposit into the database
|
||||
*
|
||||
* @param _label the label of this command
|
||||
* @param _label_dki source to use for the denomination key
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_INSERT_DEPOSIT(_label, _label_dki) \
|
||||
@ -216,7 +274,9 @@
|
||||
|
||||
/**
|
||||
* Check if a deposit is in the database
|
||||
* @param _label_deposit Label of the deposit to use
|
||||
*
|
||||
* @param _label the label of this command
|
||||
* @param _label_deposit the label of the deposit to use
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_GET_DEPOSIT(_label, _label_deposit) \
|
||||
{ \
|
||||
@ -229,6 +289,8 @@
|
||||
|
||||
/**
|
||||
* Inserts informations about a withdrawal in the database
|
||||
*
|
||||
* @param _label the label of this command
|
||||
* @param _label_dki denomination key used to sign the coin
|
||||
* @param _label_reserve reserve used to emmit the coin
|
||||
*/
|
||||
@ -246,6 +308,9 @@
|
||||
|
||||
/**
|
||||
* Polls the database about informations regarding a specific withdrawal
|
||||
*
|
||||
* @param _label the label of this command
|
||||
* @param _label_source the label of the command providing the coin to check
|
||||
*/
|
||||
#define PERF_TALER_MINTDB_INIT_CMD_GET_WITHDRAW(_label, _label_source) \
|
||||
{ \
|
||||
@ -257,8 +322,7 @@
|
||||
|
||||
|
||||
/**
|
||||
* The type of data stored
|
||||
* in a PERF_TALER_MINTDB_Type
|
||||
* The type of data stored in #PERF_TALER_MINTDB_Memory
|
||||
*/
|
||||
enum PERF_TALER_MINTDB_Type
|
||||
{
|
||||
@ -268,31 +332,32 @@ enum PERF_TALER_MINTDB_Type
|
||||
PERF_TALER_MINTDB_BLINDCOIN,
|
||||
PERF_TALER_MINTDB_RESERVE,
|
||||
PERF_TALER_MINTDB_DENOMINATION_INFO,
|
||||
PERF_TALER_MINTDB_COIN_INFO
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Structure used to handle several data type
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_Data
|
||||
{
|
||||
enum PERF_TALER_MINTDB_Type type;
|
||||
|
||||
/**
|
||||
* Storage for a variety of data type
|
||||
*/
|
||||
union PERF_TALER_MINTDB_Memory
|
||||
{
|
||||
/** #PERF_TALER_MINTDB_TIME */
|
||||
struct timespec time;
|
||||
/** #PERF_TALER_MINTDB_DEPOSIT */
|
||||
struct TALER_MINTDB_Deposit *deposit;
|
||||
/** #PERF_TALER_MINTDB_BLINDCOIN */
|
||||
struct TALER_MINTDB_CollectableBlindcoin *blindcoin;
|
||||
/** #PERF_TALER_MINTDB_RESERVE */
|
||||
struct TALER_MINTDB_Reserve *reserve;
|
||||
/** #PERF_TALER_MINTDB_DENOMINATION_INFO */
|
||||
struct TALER_MINTDB_DenominationKeyIssueInformation *dki;
|
||||
struct TALER_CoinPublicInfo *cpi;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_Data
|
||||
{
|
||||
enum PERF_TALER_MINTDB_Type type;
|
||||
union PERF_TALER_MINTDB_Memory data; // inline def.
|
||||
} data;
|
||||
};
|
||||
|
||||
|
||||
@ -311,92 +376,141 @@ enum PERF_TALER_MINTDB_CMD_Name
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_DEBUG,
|
||||
|
||||
// Define the start of al command chain loop
|
||||
/**
|
||||
* Define the start of al command chain loop
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_LOOP,
|
||||
|
||||
// Define the end of a command chain loop
|
||||
/**
|
||||
* Define the end of a command chain loop
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_END_LOOP,
|
||||
|
||||
// Save the time at which the command was executed
|
||||
/**
|
||||
* Save the time at which the command was executed
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_GET_TIME,
|
||||
|
||||
// Upload performance to Gauger
|
||||
/**
|
||||
* Upload performance to Gauger
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_GAUGER,
|
||||
|
||||
// Start a new session
|
||||
/**
|
||||
* Start a new session
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_NEW_SESSION,
|
||||
|
||||
// Start a database transaction
|
||||
/**
|
||||
* Start a database transaction
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_START_TRANSACTION,
|
||||
|
||||
// End a database transaction
|
||||
/**
|
||||
* End a database transaction
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_COMMIT_TRANSACTION,
|
||||
|
||||
// Abort a transaction
|
||||
/**
|
||||
* Abort a transaction
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_ABORT_TRANSACTION,
|
||||
|
||||
// Saves random deposits from a loop
|
||||
/**
|
||||
* Saves random deposits from a loop
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_SAVE_ARRAY,
|
||||
|
||||
// Load deposits saved earlier
|
||||
/**
|
||||
* Load deposits saved earlier
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_LOAD_ARRAY,
|
||||
|
||||
// Insert a deposit into the database
|
||||
/**
|
||||
* Insert a deposit into the database
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT,
|
||||
|
||||
// Check if a deposit is in the database
|
||||
/**
|
||||
* Check if a deposit is in the database
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_GET_DEPOSIT,
|
||||
|
||||
// Insert currency in a reserve / Create a reserve
|
||||
/**
|
||||
* Insert currency in a reserve / Create a reserve
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_INSERT_RESERVE,
|
||||
|
||||
// Get Informations about a reserve
|
||||
/**
|
||||
* Get Informations about a reserve
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_GET_RESERVE,
|
||||
|
||||
// Insert informations about a withdrawal in the database
|
||||
/**
|
||||
* Insert informations about a withdrawal in the database
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_INSERT_WITHDRAW,
|
||||
|
||||
// Pulls informations about a withdrawal from the database
|
||||
/**
|
||||
* Pulls informations about a withdrawal from the database
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_GET_WITHDRAW,
|
||||
|
||||
// Insert informations about a denomination key in the database
|
||||
/**
|
||||
* Insert informations about a denomination key in the database
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_INSERT_DENOMINATION,
|
||||
|
||||
// Polls the database for informations about a specific denomination key
|
||||
/**
|
||||
* Polls the database for informations about a specific denomination key
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_GET_DENOMINATION,
|
||||
|
||||
// Refresh a coin
|
||||
/**
|
||||
* Refresh a coin
|
||||
*/
|
||||
PERF_TALER_MINTDB_CMD_REFRESH_COIN
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Extra data requiered for the LOOP command
|
||||
* Contains extra data required for any command
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_CMD_loop_details
|
||||
union PERF_TALER_MINTDB_CMD_Details
|
||||
{
|
||||
// Maximum number of iteration in the loop
|
||||
|
||||
/**
|
||||
* Extra data requiered for the #PERF_TALER_MINTDB_CMD_LOOP command
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_CMD_loopDetails
|
||||
{
|
||||
/**
|
||||
* Maximum number of iteration in the loop
|
||||
*/
|
||||
const unsigned int max_iterations;
|
||||
/**
|
||||
* The current iteration of the loop
|
||||
*/
|
||||
unsigned int curr_iteration;
|
||||
};
|
||||
} loop;
|
||||
|
||||
|
||||
/**
|
||||
* Extra data requiered by the #PERF_TALER_MINTDB_CMD_END_LOOP command
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_CMD_loop_end_details
|
||||
struct PERF_TALER_MINTDB_CMD_endLoopDetails
|
||||
{
|
||||
/**
|
||||
* Label of the loop closed by the command
|
||||
*/
|
||||
const char *label_loop;
|
||||
};
|
||||
} end_loop;
|
||||
|
||||
|
||||
/**
|
||||
* Details about the Gauger command
|
||||
* Details about the #PERF_TALER_MINTDB_CMD_GAUGER command
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_CMD_gauger_details
|
||||
struct PERF_TALER_MINTDB_CMD_GaugerDetails
|
||||
{
|
||||
/**
|
||||
* Label of the starting timestamp
|
||||
@ -418,13 +532,13 @@ struct PERF_TALER_MINTDB_CMD_gauger_details
|
||||
* to get the result per unit
|
||||
*/
|
||||
float divide;
|
||||
};
|
||||
} gauger;
|
||||
|
||||
|
||||
/**
|
||||
* Contains extra data requiered by the SAVE_ARRAY command
|
||||
* Contains extra data requiered by the #PERF_TALER_MINTDB_CMD_SAVE_ARRAY command
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_CMD_save_array_details
|
||||
struct PERF_TALER_MINTDB_CMD_saveArrayDetails
|
||||
{
|
||||
/**
|
||||
* Number of items to save
|
||||
@ -446,13 +560,13 @@ struct PERF_TALER_MINTDB_CMD_save_array_details
|
||||
* Array of data saved
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_Data *data_saved;
|
||||
};
|
||||
} save_array;
|
||||
|
||||
|
||||
/**
|
||||
* Extra data required for the LOAD_ARRAY command
|
||||
* Extra data required for the #PERF_TALER_MINTDB_CMD_LOAD_ARRAY command
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_CMD_load_array_details
|
||||
struct PERF_TALER_MINTDB_CMD_loadArrayDetails
|
||||
{
|
||||
/**
|
||||
* The loop in which the command is located
|
||||
@ -467,59 +581,62 @@ struct PERF_TALER_MINTDB_CMD_load_array_details
|
||||
/**
|
||||
* A permutation array used to randomize the order the items are loaded in
|
||||
*/
|
||||
unsigned int *permutation; // A permutation array to randomize the order the deposits are loaded in
|
||||
};
|
||||
unsigned int *permutation;
|
||||
} load_array;
|
||||
|
||||
|
||||
/**
|
||||
* Data used by the command insert_deposit
|
||||
* Data used by the #PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT command
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_CMD_insert_deposit_details
|
||||
struct PERF_TALER_MINTDB_CMD_insertDepositDetails
|
||||
{
|
||||
/**
|
||||
* Label of the source where the reserve used to create the coin is
|
||||
*/
|
||||
const char *label_dki;
|
||||
};
|
||||
} insert_deposit;
|
||||
|
||||
|
||||
/**
|
||||
* Extra data requiered for the GET_DEPOSIT command
|
||||
* Extra data requiered for the #PERF_TALER_MINTDB_CMD_GET_DEPOSIT command
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_CMD_get_deposit_details
|
||||
struct PERF_TALER_MINTDB_CMD_getDepositDetails
|
||||
{
|
||||
/**
|
||||
* The label of the source of the deposit to check
|
||||
*/
|
||||
const char *label_source;
|
||||
};
|
||||
} get_deposit;
|
||||
|
||||
|
||||
/**
|
||||
* Extra data requiered for the GET_DEPOSIT command
|
||||
* Extra data requiered for the #PERF_TALER_MINTDB_CMD_GET_RESERVE command
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_CMD_get_reserve_details
|
||||
struct PERF_TALER_MINTDB_CMD_getReserveDetails
|
||||
{
|
||||
/**
|
||||
* The label of the source of the reserve to check
|
||||
*/
|
||||
const char *label_source;
|
||||
};
|
||||
} get_reserve;
|
||||
|
||||
|
||||
struct PERF_TALER_MINTDB_CMD_get_denomination_details
|
||||
/**
|
||||
* Extra data requiered by the #PERF_TALER_MINTDB_CMD_GET_DENOMINATION command
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_CMD_getDenominationDetails
|
||||
{
|
||||
/**
|
||||
* The label of the source of the denomination to check
|
||||
*/
|
||||
const char *label_source;
|
||||
};
|
||||
} get_denomination;
|
||||
|
||||
|
||||
/**
|
||||
* Extra data related to the get withdraw command
|
||||
* Extra data related to the #PERF_TALER_MINTDB_CMD_GET_WITHDRAW command
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_CMD_insert_withdraw_details
|
||||
struct PERF_TALER_MINTDB_CMD_insertWithdrawDetails
|
||||
{
|
||||
/**
|
||||
* label of the denomination key used to sign the coin
|
||||
@ -530,36 +647,7 @@ struct PERF_TALER_MINTDB_CMD_insert_withdraw_details
|
||||
* label of the reserve the money to mint the coin comes from
|
||||
*/
|
||||
const char *label_reserve;
|
||||
};
|
||||
|
||||
/**
|
||||
* Extra data requiered for refreshing coins
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_CMD_refresh_coin_details
|
||||
{
|
||||
/**
|
||||
* The label of the coin to refresh
|
||||
*/
|
||||
const char *label_source;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Contains extra data required for any command
|
||||
*/
|
||||
union PERF_TALER_MINTDB_CMD_Details
|
||||
{
|
||||
struct PERF_TALER_MINTDB_CMD_loop_details loop;
|
||||
struct PERF_TALER_MINTDB_CMD_loop_end_details end_loop;
|
||||
struct PERF_TALER_MINTDB_CMD_gauger_details gauger;
|
||||
struct PERF_TALER_MINTDB_CMD_save_array_details save_array;
|
||||
struct PERF_TALER_MINTDB_CMD_load_array_details load_array;
|
||||
struct PERF_TALER_MINTDB_CMD_insert_deposit_details insert_deposit;
|
||||
struct PERF_TALER_MINTDB_CMD_get_deposit_details get_deposit;
|
||||
struct PERF_TALER_MINTDB_CMD_get_reserve_details get_reserve;
|
||||
struct PERF_TALER_MINTDB_CMD_get_denomination_details get_denomination;
|
||||
struct PERF_TALER_MINTDB_CMD_refresh_coin_details refresh;
|
||||
struct PERF_TALER_MINTDB_CMD_insert_withdraw_details insert_withdraw;
|
||||
} insert_withdraw;
|
||||
};
|
||||
|
||||
|
||||
@ -590,9 +678,28 @@ struct PERF_TALER_MINTDB_Cmd
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param benchmark_name the name of the benchmark, displayed in the logs
|
||||
* @param configuration_file path to the taler configuration file to use
|
||||
* @param init the commands to use for the database initialisation,
|
||||
* if #NULL the standard initialization is used
|
||||
* @param benchmark the commands for the benchmark
|
||||
* @return GNUNET_OK upon success; GNUNET_SYSERR upon failure
|
||||
*/
|
||||
int
|
||||
PERF_TALER_MINTDB_run_benchmark (const char *benchmark_name,
|
||||
const char *configuration_file,
|
||||
struct PERF_TALER_MINTDB_Cmd *init,
|
||||
struct PERF_TALER_MINTDB_Cmd *benchmark);
|
||||
|
||||
|
||||
/**
|
||||
* Runs the command array @a cmd
|
||||
* using @a db_plugin to connect to the database
|
||||
*
|
||||
* @param db_plugin the connection to the database
|
||||
* @param cmd the commands to run
|
||||
*/
|
||||
int
|
||||
PERF_TALER_MINTDB_interpret(
|
||||
|
@ -22,17 +22,4 @@
|
||||
#define __PERF_TALER_MINTDB__VALUES_H__
|
||||
|
||||
|
||||
#define PERF_TALER_MINTDB_NB_DENOMINATION_INIT 10
|
||||
#define PERF_TALER_MINTDB_NB_DENOMINATION_SAVE 10
|
||||
|
||||
#define PERF_TALER_MINTDB_NB_RESERVE_INIT 100
|
||||
#define PERF_TALER_MINTDB_NB_RESERVE_SAVE 10
|
||||
|
||||
|
||||
#define PERF_TALER_MINTDB_NB_DEPOSIT_INIT 100
|
||||
#define PERF_TALER_MINTDB_NB_DEPOSIT_SAVE 10
|
||||
|
||||
|
||||
#define PERF_TALER_MINTDB_NB_WITHDRAW_INIT 100
|
||||
#define PERF_TALER_MINTDB_NB_WITHDRAW_SAVE 10
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user