Added headers to files and commented
This commit is contained in:
parent
3390717e33
commit
e40cbd96dd
@ -1,13 +1,32 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2014, 2015 Christian Grothoff (and other contributing authors)
|
||||
|
||||
TALER is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
/**
|
||||
* @file mintdb/perf_taler_mintdb.c
|
||||
* @brief Mint database performance analysis
|
||||
* @author Nicolas Fournier
|
||||
*/
|
||||
#include "perf_taler_mintdb_interpreter.h"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Runs the performances tests for the mint database
|
||||
*/
|
||||
int
|
||||
main(int argc, char ** argv)
|
||||
{
|
||||
|
||||
|
||||
struct PERF_TALER_MINTDB_CMD test[] =
|
||||
{
|
||||
INIT_CMD_LOOP("loop_db_init_deposit",100000),
|
||||
|
@ -1,16 +1,35 @@
|
||||
#include <gnunet/platform.h>
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2014, 2015 Christian Grothoff (and other contributing authors)
|
||||
|
||||
TALER is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
/**
|
||||
* @file mintdb/perf_taler_mintdb_init.c
|
||||
* @brief Interpreter library for mint database performance analysis
|
||||
* @author Nicolas Fournier
|
||||
*/
|
||||
#include "platform.h"
|
||||
#include <gnunet/gnunet_crypto_lib.h>
|
||||
#include <gnunet/gnunet_signatures.h>
|
||||
|
||||
#include <taler/taler_mintdb_plugin.h>
|
||||
#include <taler/taler_signatures.h>
|
||||
#include <taler/taler_amount_lib.h>
|
||||
#include "taler_mintdb_plugin.h"
|
||||
#include "taler_signatures.h"
|
||||
#include "taler_amount_lib.h"
|
||||
|
||||
|
||||
#define CURRENCY "EUR\0\0\0\0\0\0\0\0"
|
||||
#define CURRENCY "EUR"
|
||||
|
||||
struct TALER_MINTDB_CollectableBlindcoin *
|
||||
init_CollectableBlindcoin ()
|
||||
collectable_blindcoin_init ()
|
||||
{
|
||||
// indent by 2 spaces
|
||||
struct TALER_MINTDB_CollectableBlindcoin *coin = GNUNET_new (*coin);
|
||||
@ -52,9 +71,27 @@ init_CollectableBlindcoin ()
|
||||
return coin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a randomly generated blindcoin
|
||||
*/
|
||||
int
|
||||
collectable_blindcoin_free(struct TALER_MINTDB_CollectableBlindcoin *coin)
|
||||
{
|
||||
GNUNET_free(coin->sig.rsa_signature);
|
||||
GNUNET_free(coin->denom_pub.rsa_public_key);
|
||||
|
||||
GNUNET_free(coin);
|
||||
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return a randomly generated reserve
|
||||
*/
|
||||
struct TALER_MINTDB_Reserve *
|
||||
init_Reserve(){
|
||||
reserve_init()
|
||||
{
|
||||
struct TALER_MINTDB_Reserve *reserve = GNUNET_malloc(sizeof(*reserve));
|
||||
struct GNUNET_CRYPTO_EddsaPrivateKey *reserve_priv = GNUNET_CRYPTO_eddsa_key_create();
|
||||
|
||||
@ -70,7 +107,8 @@ init_Reserve(){
|
||||
|
||||
|
||||
struct TALER_MINTDB_RefreshSession *
|
||||
init_Refresh_session(){
|
||||
refresh_session_init()
|
||||
{
|
||||
struct TALER_MINTDB_RefreshSession *refresh_session = GNUNET_malloc(sizeof(*refresh_session));
|
||||
|
||||
refresh_session->noreveal_index = 1;
|
||||
@ -82,7 +120,8 @@ init_Refresh_session(){
|
||||
|
||||
|
||||
struct TALER_MINTDB_Deposit *
|
||||
init_Deposit(){
|
||||
deposit_init()
|
||||
{
|
||||
static int transaction_id = 0;
|
||||
|
||||
struct TALER_MINTDB_Deposit *deposit = GNUNET_malloc(sizeof(*deposit));
|
||||
@ -167,8 +206,21 @@ init_Deposit(){
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
deposit_free(struct TALER_MINTDB_Deposit *deposit)
|
||||
{
|
||||
GNUNET_free(deposit->coin.denom_pub.rsa_public_key);
|
||||
GNUNET_free(deposit->coin.denom_sig.rsa_signature);
|
||||
|
||||
GNUNET_free(deposit);
|
||||
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
struct TALER_MINTDB_DenominationKeyIssueInformation *
|
||||
init_denomination(){
|
||||
denomination_init()
|
||||
{
|
||||
struct TALER_MINTDB_DenominationKeyIssueInformation *dki = GNUNET_malloc(sizeof(&dki));
|
||||
|
||||
|
||||
@ -220,38 +272,9 @@ init_denomination(){
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Destructors
|
||||
|
||||
|
||||
int
|
||||
free_deposit(struct TALER_MINTDB_Deposit *deposit){
|
||||
GNUNET_free(deposit->coin.denom_pub.rsa_public_key);
|
||||
GNUNET_free(deposit->coin.denom_sig.rsa_signature);
|
||||
|
||||
GNUNET_free(deposit);
|
||||
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
free_coin(struct TALER_MINTDB_CollectableBlindcoin *coin){
|
||||
GNUNET_free(coin->sig.rsa_signature);
|
||||
GNUNET_free(coin->denom_pub.rsa_public_key);
|
||||
|
||||
GNUNET_free(coin);
|
||||
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
free_denomination(struct TALER_MINTDB_DenominationKeyIssueInformation *dki){
|
||||
denomination_free(struct TALER_MINTDB_DenominationKeyIssueInformation *dki)
|
||||
{
|
||||
GNUNET_free(dki->denom_priv.rsa_private_key);
|
||||
GNUNET_free(dki->denom_pub.rsa_public_key);
|
||||
|
||||
|
@ -1,11 +1,30 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2014, 2015 Christian Grothoff (and other contributing authors)
|
||||
|
||||
TALER is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
/**
|
||||
* @file mintdb/perf_taler_mintdb_init.h
|
||||
* @brief Heler function for creating dummy inpus for the mint database
|
||||
* @author Nicolas Fournier
|
||||
*/
|
||||
#ifndef __PERF_TALER_MINTDB_INIT_H___
|
||||
#define __PERF_TALER_MINTDB_INIT_H___
|
||||
|
||||
|
||||
#include <gnunet/platform.h>
|
||||
|
||||
#include <taler/taler_mintdb_lib.h>
|
||||
#include <taler/taler_mintdb_plugin.h>
|
||||
#include "taler_mintdb_lib.h"
|
||||
#include "taler_mintdb_plugin.h"
|
||||
|
||||
|
||||
#define CURRENCY "EUR"
|
||||
|
@ -1,18 +1,36 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2014, 2015 Christian Grothoff (and other contributing authors)
|
||||
|
||||
TALER is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
/**
|
||||
* @file mintdb/perf_taler_mintdb_interpreter.c
|
||||
* @brief Interpreter library for mint database performance analysis
|
||||
* @author Nicolas Fournier
|
||||
*/
|
||||
#include "perf_taler_mintdb_interpreter.h"
|
||||
|
||||
#include "perf_taler_mintdb_init.h"
|
||||
|
||||
#include <gauger.h>
|
||||
#include "gauger.h"
|
||||
|
||||
|
||||
/**
|
||||
* Finds the first command in cmd with the name search
|
||||
*
|
||||
* \return the index of the first command with name search
|
||||
* @return the index of the first command with name search
|
||||
* GNUNET_SYSERR if none found
|
||||
*/
|
||||
static int
|
||||
cmd_find(const struct PERF_TALER_MINTDB_CMD *cmd, const char *search)
|
||||
static int
|
||||
cmd_find(const struct PERF_TALER_MINTDB_Cmd *cmd, const char *search)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -24,46 +42,32 @@ cmd_find(const struct PERF_TALER_MINTDB_CMD *cmd, const char *search)
|
||||
|
||||
|
||||
// Initialization of a command array
|
||||
static int
|
||||
static int
|
||||
cmd_init(struct PERF_TALER_MINTDB_CMD cmd[])
|
||||
{
|
||||
int i = 0;
|
||||
while (CMD_END != cmd[i].command)
|
||||
for (i=0; PERF_TALER_MINTDB_CMD_END != cmd[i].command; i++)
|
||||
{
|
||||
switch (cmd[i].command)
|
||||
{
|
||||
case CMD_SAVE_ARRAY:
|
||||
// Initialization is done differently depending of the type saved
|
||||
switch (cmd[i].details.save_array.saved_type)
|
||||
{
|
||||
case DEPOSIT:
|
||||
cmd[i].details.save_array.saved_data.deposit =
|
||||
GNUNET_malloc(cmd[i].details.save_array.nb*
|
||||
sizeof(*cmd[i].details.save_array.saved_data.deposit));
|
||||
break;
|
||||
case TIME:
|
||||
cmd[i].details.save_array.saved_data.time =
|
||||
GNUNET_malloc(cmd[i].details.save_array.nb*
|
||||
sizeof(*cmd[i].details.save_array.saved_data.time));
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// Allocation of memmory for saving data
|
||||
case PERF_TALER_MINTDB_CMD_SAVE_ARRAY:
|
||||
cmd[i].details.save_array.saved_data =
|
||||
GNUNET_new_array(cmd[i].details.nb, union PERF_TALER_MINTDB_Data);
|
||||
break;
|
||||
|
||||
case CMD_LOAD_ARRAY:
|
||||
// Creation of the permutation array
|
||||
case PERF_TALER_MINTDB_CMD_LOAD_ARRAY:
|
||||
cmd[i].details.load_array.permutation =
|
||||
GNUNET_CRYPTO_random_permute(
|
||||
GNUNET_CRYPTO_QUALITY_WEAK,
|
||||
cmd[i].details.load_array.nb);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
return GNUNET_OK;
|
||||
}
|
||||
|
||||
@ -75,7 +79,7 @@ cmd_init(struct PERF_TALER_MINTDB_CMD cmd[])
|
||||
cmd_clean(struct PERF_TALER_MINTDB_CMD cmd[])
|
||||
{
|
||||
int i = 0;
|
||||
while (cmd[i].command != CMD_END)
|
||||
for(i=0; PERF_TALER_MINTDB_CMD_END != cmd[i].command; i++)
|
||||
{
|
||||
switch (cmd[i].command)
|
||||
{
|
||||
@ -84,21 +88,19 @@ cmd_clean(struct PERF_TALER_MINTDB_CMD cmd[])
|
||||
int j;
|
||||
switch (cmd[i].details.save_array.saved_type)
|
||||
{
|
||||
case DEPOSIT:
|
||||
case PERF_TALER_MINTDB_DEPOSIT:
|
||||
for (j = 0; j < cmd[i].details.save_array.nb; j++)
|
||||
{
|
||||
free_deposit(cmd[i].details.save_array.saved_data.deposit[j]);
|
||||
deposit_free(cmd[i].details.save_array.saved_data.deposit[j]);
|
||||
cmd[i].details.save_array.saved_data.deposit[j] = NULL;
|
||||
}
|
||||
GNUNET_free(cmd[i].details.save_array.saved_data.deposit);
|
||||
cmd[i].details.save_array.saved_data.deposit = NULL;
|
||||
break;
|
||||
case TIME:
|
||||
GNUNET_free(cmd[i].details.save_array.saved_data.time);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
cmd[i].details.save_array.saved_data.deposit = NULL;
|
||||
}
|
||||
|
||||
case CMD_INSERT_DEPOSIT:
|
||||
@ -116,88 +118,94 @@ cmd_clean(struct PERF_TALER_MINTDB_CMD cmd[])
|
||||
i++;
|
||||
}
|
||||
return GNUNET_OK;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* /TODO cut it into pieces
|
||||
*/
|
||||
static int
|
||||
interprete(struct TALER_MINTDB_Plugin *db_plugin,
|
||||
static int
|
||||
interpret(struct TALER_MINTDB_Plugin *db_plugin,
|
||||
struct TALER_MINTDB_Session*session,
|
||||
struct PERF_TALER_MINTDB_CMD cmd[])
|
||||
{
|
||||
int i=0;
|
||||
while (0){
|
||||
for(i=0; PERF_TALER_MINTDB_MD_END == cmd[i].command; i++)
|
||||
{
|
||||
switch (cmd[i].command)
|
||||
{
|
||||
case CMD_END:
|
||||
case PERF_TALER_MINTDB_CMD_END:
|
||||
return GNUNET_YES;
|
||||
|
||||
case CMD_LOOP:
|
||||
case PERF_TALER_MINTDB_CMD_LOOP:
|
||||
cmd[i].details.loop.curr_iteration++;
|
||||
break;
|
||||
|
||||
case CMD_END_LOOP:
|
||||
case PERF_TALER_MINTDB_CMD_END_LOOP:
|
||||
{
|
||||
int jump = cmd_find(cmd, cmd[i].details.end_loop.loop_start);
|
||||
zf (cmd[jump].details.loop.max_iterations > cmd[jump].details.loop.curr_iteration)
|
||||
int jump = cmd_find(cmd, cmd[i].details.end_loop.label_loop);
|
||||
if (cmd[jump].details.loop.max_iterations > cmd[jump].details.loop.curr_iteration)
|
||||
{
|
||||
i = jump -1;
|
||||
}else{
|
||||
int j;
|
||||
// For each command in the loop
|
||||
for (j = 0; j <i; j++){
|
||||
// If the exposed variable has not been copied
|
||||
if (!cmd[j].exposed_used)
|
||||
// Reseting loop counter
|
||||
cmd[jump].details.loop.curr_iteration = -1;
|
||||
}
|
||||
// Cleaning up the memory in the loop
|
||||
int j;
|
||||
// For each command in the loop
|
||||
for (j = jump; j < i; j++)
|
||||
{
|
||||
// If the exposed variable has not been copied
|
||||
if ( 0 == cmd[j].exposed_saved)
|
||||
{
|
||||
// It is freed
|
||||
switch (cmd[j].exposed_type)
|
||||
{
|
||||
cmd[j].exposed_used = 0;
|
||||
// It is freed
|
||||
switch (cmd[j].command){
|
||||
case CMD_INSERT_DEPOSIT:
|
||||
free_deposit(cmd[j].exposed.deposit);
|
||||
cmd[j].exposed.deposit = NULL;
|
||||
break;
|
||||
case PERF_TALER_MINTDB_DEPOSIT:
|
||||
free_deposit(cmd[j].exposed.deposit);
|
||||
cmd[j].exposed.deposit = NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
cmd[j].exposed_saved = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case CMD_GET_TIME:
|
||||
case PERF_TALER_MINTDB_CMD_GET_TIME:
|
||||
clock_gettime(CLOCK_MONOTONIC, &cmd[i].exposed.time);
|
||||
break;
|
||||
|
||||
|
||||
case CMD_GAUGER:
|
||||
case PERF_TALER_MINTDB_CMD_GAUGER:
|
||||
{
|
||||
int start_index = cmd_find(cmd, cmd[i].details.gauger.start_time);
|
||||
int stop_index = cmd_find(cmd, cmd[i].details.gauger.stop_time );
|
||||
struct timespec start= cmd[start_index].exposed.time;
|
||||
struct timespec stop = cmd[stop_index].exposed.time;
|
||||
int start_index = cmd_find (cmd, cmd[i].details.gauger.label_start);
|
||||
int stop_index = cmd_find (cmd, cmd[i].details.gauger.label_stop);
|
||||
struct timespec start = cmd [start_index].exposed.time;
|
||||
struct timespec stop = cmd [stop_index].exposed.time;
|
||||
|
||||
unsigned long elapsed_ms = (start.tv_sec - stop.tv_sec)*1000 + (start.tv_nsec - stop.tv_nsec)/1000000;
|
||||
unsigned long elapsed_ms = (start.tv_sec - stop.tv_sec) * 1000 + (start.tv_nsec - stop.tv_nsec) / 1000000;
|
||||
|
||||
GAUGER("MINTDB", cmd[i].details.gauger.description, elapsed_ms, "milliseconds");
|
||||
GAUGER ("MINTDB", cmd[i].details.gauger.description, elapsed_ms, "milliseconds");
|
||||
}
|
||||
break;
|
||||
|
||||
case CMD_START_TRANSACTION:
|
||||
case PERF_TALER_MINTDB_CMD_START_TRANSACTION:
|
||||
db_plugin->start(db_plugin->cls, session);
|
||||
break;
|
||||
|
||||
|
||||
case CMD_COMMIT_TRANSACTION:
|
||||
case PERF_TALER_MINTDB_CMD_COMMIT_TRANSACTION:
|
||||
db_plugin->commit(db_plugin->cls, session);
|
||||
break;
|
||||
|
||||
|
||||
case CMD_INSERT_DEPOSIT:
|
||||
case PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT:
|
||||
{
|
||||
struct TALER_MINTDB_Deposit *deposit = init_deposit(0);
|
||||
db_plugin->insert_deposit(db_plugin->cls, session, deposit);
|
||||
@ -207,7 +215,7 @@ interprete(struct TALER_MINTDB_Plugin *db_plugin,
|
||||
break;
|
||||
|
||||
|
||||
case CMD_GET_DEPOSIT:
|
||||
case PERF_TALER_MINTDB_CMD_GET_DEPOSIT:
|
||||
{
|
||||
int source_index = cmd_find(cmd, cmd[i].details.get_deposit.source); // Find the source location
|
||||
struct TALER_MINTDB_Deposit *deposit = cmd[source_index].exposed.deposit; // Get the deposit from the source
|
||||
@ -216,69 +224,76 @@ interprete(struct TALER_MINTDB_Plugin *db_plugin,
|
||||
break;
|
||||
|
||||
|
||||
case CMD_SAVE_ARRAY:
|
||||
case PERF_TALER_MINTDB_CMD_SAVE_ARRAY:
|
||||
{
|
||||
// Array initialization on first loop iteration
|
||||
if (cmd[cmd_find(cmd, cmd[i].details.save_array.loop)].details.loop.curr_iteration == 0)
|
||||
// Alows for nested loops
|
||||
if (cmd[cmd_find(cmd, cmd[i].details.save_array.label_loop)].details.loop.curr_iteration == 0)
|
||||
{
|
||||
cmd[i].details.save_array.index = 0;
|
||||
}
|
||||
|
||||
int loop_index = cmd_find(cmd, cmd[i].details.save_array.loop);
|
||||
int proba = cmd[loop_index].details.loop.max_iterations / cmd[i].details.save_array.nb;
|
||||
int loop_index = cmd_find(cmd, cmd[i].details.save_array.label_loop);
|
||||
int proba = cmd[loop_index].details.loop.max_iterations / cmd[i].details.save_array.nb_saved;
|
||||
int rnd = GNUNET_CRYPTO_random_u32(GNUNET_CRYPTO_QUALITY_WEAK, proba);
|
||||
|
||||
// If there is a lesser or equal number of iteration next than room remain in the array
|
||||
if ((cmd[loop_index].details.loop.max_iterations - cmd[loop_index].details.loop.curr_iteration <=
|
||||
cmd[i].details.save_array.nb - cmd[i].details.save_array.index) ||
|
||||
(rnd == 0 && cmd[i].details.save_array.index < cmd[i].details.save_array.nb))
|
||||
cmd[i].details.save_array.nb_saved - cmd[i].details.save_array.index) ||
|
||||
(rnd == 0 && cmd[i].details.save_array.index < cmd[i].details.save_array.nb_saved))
|
||||
{
|
||||
|
||||
// We automaticly save the whatever we need to
|
||||
switch (cmd[i].details.save_array.saved_type){
|
||||
case DEPOSIT:
|
||||
switch (cmd[i].details.save_array.saved_type)
|
||||
{
|
||||
case PERF_TALER_MINTDB_DEPOSIT:
|
||||
cmd[i].details.save_array.saved_data.deposit[cmd[i].details.save_array.index] =
|
||||
cmd[cmd_find(cmd, cmd[i].details.save_array.saved)].exposed.deposit;
|
||||
cmd[cmd_find (cmd, cmd[i].details.save_array.label_saved)].exposed.deposit;
|
||||
break;
|
||||
case TIME:
|
||||
|
||||
case PERF_TALER_MINTDB_TIME:
|
||||
cmd[i].details.save_array.saved_data.deposit[cmd[i].details.save_array.index] =
|
||||
cmd[cmd_find(cmd, cmd[i].details.save_array.saved)].exposed.deposit;
|
||||
cmd[cmd_find (cmd, cmd[i].details.save_array.label_saved)].exposed.time;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
cmd[cmd_find (cmd, cmd[i].details.save_array.label_saved)].exposed_use = 1;
|
||||
cmd[i].details.save_array.index++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case CMD_LOAD_ARRAY:
|
||||
case PERF_TALER_MINTDB_CMD_LOAD_ARRAY:
|
||||
{
|
||||
|
||||
int loop_index = cmd_find(cmd, cmd[i].details.load_array.loop);
|
||||
int save_index = cmd_find(cmd, cmd[i].details.load_array.saved);
|
||||
switch (cmd[i].details.load_array.loaded_type){
|
||||
case DEPOSIT:
|
||||
case PERF_TALER_MINTDB_DEPOSIT:
|
||||
cmd[i].exposed.deposit = cmd[save_index].details.save_array.saved_data.deposit[
|
||||
cmd[i].details.load_array.permutation[
|
||||
cmd[loop_index].details.loop.curr_iteration
|
||||
cmd[loop_index].details.loop.curr_iteration
|
||||
]
|
||||
];
|
||||
break;
|
||||
break;
|
||||
|
||||
case PERF_TALER_MINTDB_TIME:
|
||||
cmd[i].exposed.time = cmd[save_index].details.save_array.saved_data.time[
|
||||
cmd[i].details.load_array.permutation[
|
||||
cmd[loop_index].details.loop.curr_iteration
|
||||
]
|
||||
];
|
||||
break;
|
||||
|
||||
case TIME:
|
||||
cmd[i].exposed.time = cmd[save_index].details.save_array.saved_data.time[
|
||||
cmd[i].details.load_array.permutation[
|
||||
cmd[loop_index].details.loop.curr_iteration
|
||||
]
|
||||
];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
default :
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return GNUNET_OK;
|
||||
}
|
||||
@ -292,7 +307,6 @@ PERF_TALER_MINTDB_interprete(struct TALER_MINTDB_Plugin *db_plugin,
|
||||
struct TALER_MINTDB_Session *session,
|
||||
struct PERF_TALER_MINTDB_CMD cmd[])
|
||||
{
|
||||
|
||||
// Initializing commands
|
||||
cmd_init(cmd);
|
||||
|
||||
@ -303,5 +317,4 @@ PERF_TALER_MINTDB_interprete(struct TALER_MINTDB_Plugin *db_plugin,
|
||||
cmd_clean(cmd);
|
||||
|
||||
return GNUNET_YES;
|
||||
|
||||
}
|
||||
|
@ -1,153 +1,360 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2014, 2015 Christian Grothoff (and other contributing authors)
|
||||
|
||||
TALER is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
/**
|
||||
* @file mintdb/perf_taler_mintdb_interpreter.h
|
||||
* @brief Library for performance analysis of taler database
|
||||
* @author Nicolas Fournier
|
||||
*/
|
||||
|
||||
#ifndef __PERF_TALER_MINTDB_INTERPRETER_H__
|
||||
#define __PERF_TALER_MINTDB_INTERPRETER_H__
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <gnunet/platform.h>
|
||||
#include <taler/taler_mintdb_lib.h>
|
||||
#include <taler/taler_mintdb_plugin.h>
|
||||
#include "taler_mintdb_lib.h"
|
||||
#include "taler_mintdb_plugin.h"
|
||||
|
||||
/**
|
||||
* Marks the end of the command chain
|
||||
* @param _label
|
||||
*/
|
||||
#define INIT_CMD_END(label) {.command = PERF_TALER_MINTDB_CMD_END, .label = _label}
|
||||
|
||||
#define INIT_CMD_END(label) {.command = CMD_END, .name = label}
|
||||
|
||||
#define INIT_CMD_LOOP(label, _iter) { \
|
||||
.command = CMD_LOOP, \
|
||||
.name = label, \
|
||||
/**
|
||||
* The begining of a loop
|
||||
* @param _label the name of the loop
|
||||
* @param _iter the number of iteration of the loop
|
||||
*/
|
||||
#define INIT_CMD_LOOP(_label, _iter) \
|
||||
{ \
|
||||
.command = PERF_TALER_MINTDB_CMD_LOOP, \
|
||||
.label = _label, \
|
||||
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
||||
.details.loop = { \
|
||||
.max_iterations = _iter, \
|
||||
.curr_iteration = -1} \
|
||||
}
|
||||
}
|
||||
|
||||
#define INIT_CMD_END_LOOP(label, _loopname) {.command = CMD_END_LOOP, .name = label, .details.end_loop.loop_start = _loopname}
|
||||
/**
|
||||
* Marks the end of the loop @_label_loop
|
||||
*/
|
||||
#define INIT_CMD_END_LOOP(_label, _label_loop) \
|
||||
{\
|
||||
.command = PERF_TALER_MINTDB_CMD_END_LOOP,\
|
||||
.label = _label,\
|
||||
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
||||
.details.end_loop.label_loop = _label_loop \
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the time of execution to use for logging with gauger
|
||||
*/
|
||||
#define INIT_CMD_GET_TIME(_label) \
|
||||
{ \
|
||||
.command = PERF_TALER_MINTDB_CMD_GET_TIME, \
|
||||
.label = _label \
|
||||
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
||||
}
|
||||
|
||||
#define INIT_CMD_GET_TIME(label) {.command = CMD_GET_TIME, .name = label}
|
||||
/**
|
||||
* Commits the duration between @a _label_start and @a _label_stop
|
||||
* to Gauger with @a _description explaining
|
||||
*/
|
||||
#define INIT_CMD_GAUGER(_label, _start_time, _stop_time, _description) \
|
||||
{ \
|
||||
.command = PERF_TALER_MINTDB_CMD_GAUGER, \
|
||||
.label = _label, \
|
||||
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
||||
.details.gauger = { \
|
||||
.label_start = _label_start, \
|
||||
.label_end = _label_end, \
|
||||
.description = _description \
|
||||
} \
|
||||
}
|
||||
|
||||
#define INIT_CMD_GAUGER(label, _start_time, _stop_time, _description) {.command = CMD_GAUGER, .name = label, .details.gauger = {.start_time = _start_time, .end_time = _endtime, .description = _description} }
|
||||
/**
|
||||
* Initiate a database transaction
|
||||
*/
|
||||
#define INIT_CMD_START_TRANSACTION(_label) \
|
||||
{ \
|
||||
.command = PERF_TALER_MINTDB_CMD_START_TRANSACTION, \
|
||||
.label = _label \
|
||||
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
||||
}
|
||||
|
||||
#define INIT_CMD_START_TRANSACTION(label) {.command = CMD_START_TRANSACTION, .name = label}
|
||||
/**
|
||||
* Commits a database connection
|
||||
*/
|
||||
#define INIT_CMD_COMMIT_TRANSACTION(_label) \
|
||||
{ \
|
||||
.command = PERF_TALER_MINTDB_CMD_COMMIT_TRANSACTION, \
|
||||
.label = _label \
|
||||
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
||||
}
|
||||
|
||||
#define INIT_CMD_COMMIT_TRANSACTION(label) {.command = CMD_COMMIT_TRANSACTION, .name = label}
|
||||
/**
|
||||
* Insert a deposit into the database
|
||||
*/
|
||||
#define INIT_CMD_INSERT_DEPOSIT(_label) \
|
||||
{ \
|
||||
.command = PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT,\
|
||||
.label = label \
|
||||
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a deposit is in the database
|
||||
* @param _label_deposit Label of the deposit to use
|
||||
*/
|
||||
#define INIT_CMD_GET_DEPOSIT(_label, _label_deposit) \
|
||||
{ \
|
||||
.command = PERF_TALER_MINTDB_CMD_GET_DEPOSIT, \
|
||||
.label = _label, \
|
||||
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
||||
.details.label_deposit.saved = _label_deposit \
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts @a _nb_saved items of type @a _save_type
|
||||
* from the command @a _label_save during the loop @a _label_loop
|
||||
*/
|
||||
#define INIT_CMD_SAMPLE_ARRAY(_label, _label_loop, _label_save, _nb_saved, _save_type) \
|
||||
{ \
|
||||
.command = PERF_TALER_MINTDB_CMD_SAVE_ARRAY, \
|
||||
.label = _label, \
|
||||
.exposed_type = PERF_TALER_MINTDB_NONE, \
|
||||
.details.save_array = { \
|
||||
.label_loop = _label_loop, \
|
||||
.label_save = _label_save, \
|
||||
.nb_saved = _nb_saved, \
|
||||
.save_type = _save_type \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads @a _nb_saved previously sampled data of type @a _saved_type
|
||||
* from @a _label_save during the loop @a _label_loop
|
||||
*/
|
||||
#define INIT_CMD_LOAD_ARRAY(_label, _label_loop, _label_save, _nb_saved, _save_type) \
|
||||
{ \
|
||||
.command = PERF_TALER_MINTDB_CMD_LOAD_ARRAY, \
|
||||
.label = _label, \
|
||||
.exposed_type = _saved_type_, \
|
||||
.details.load_array = { \
|
||||
.label_loop = _label_loop, \
|
||||
.label_save = _label_save \
|
||||
.nb_saved = _nb_saved, \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define INIT_CMD_INSERT_DEPOSIT(label) {.command = CMD_INSERT_DEPOSIT, .name = label}
|
||||
|
||||
#define INIT_CMD_GET_DEPOSIT(label, _saved) {.command = CMD_GET_DEPOSIT, .name = label, .details.get_deposit.saved = _source }
|
||||
|
||||
#define INIT_CMD_SAVE_DEPOSIT(label, _loop, _save, _nb) {.command = CMD_SAVE_ARRAY, .name = label, .details.save_array = {.loop = _loop, .nb = _nb, .saved = _save, saved_type = DEPOSIT} }
|
||||
|
||||
#define INIT_CMD_LOAD_DEPOSIT(label, _loop, _save, _nb) {.command = CMD_LOAD_ARRAY, .name = label, .details.load_array = {.loop = _loop, .nb = _nb, .saved = _save} }
|
||||
|
||||
|
||||
|
||||
enum PERF_TALER_MINTDB_TYPE {
|
||||
DEPOSIT,
|
||||
TIME,
|
||||
/**
|
||||
* The type of data stored
|
||||
*/
|
||||
enum PERF_TALER_MINTDB_Type
|
||||
{
|
||||
PERF_TALER_MINTDB_NONE,
|
||||
PERF_TALER_MINTDB_DEPOSIT,
|
||||
PERF_TALER_MINTDB_TIME,
|
||||
};
|
||||
|
||||
/**
|
||||
* Command to be interpreted.
|
||||
*
|
||||
* Storage for a variety of data type
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_CMD{
|
||||
union PERF_TALER_MINTDB_Data
|
||||
{
|
||||
struct TALER_MINTDB_Deposit *deposit;
|
||||
struct timespec time;
|
||||
};
|
||||
|
||||
enum {
|
||||
/**
|
||||
* Name of the command
|
||||
*/
|
||||
enum PERF_TALER_MINTDB_CMD_Name
|
||||
{
|
||||
// All comand chain must hace this as their last command
|
||||
PERF_TALER_MINTDB_CMD_END,
|
||||
|
||||
// Define the start of al command chain loop
|
||||
CMD_LOOP,
|
||||
// Define the end of a command chain loop
|
||||
CMD_END_LOOP,
|
||||
// Define the start of al command chain loop
|
||||
PERF_TALER_MINTDB_CMD_LOOP,
|
||||
//
|
||||
// Define the end of a command chain loop
|
||||
PERF_TALER_MINTDB_CMD_END_LOOP,
|
||||
|
||||
// All comand chain must hace this as their last command
|
||||
CMD_END,
|
||||
// Save the time at which the command was executed
|
||||
PERF_TALER_MINTDB_CMD_GET_TIME,
|
||||
|
||||
// Save the time at which the command was executed
|
||||
CMD_GET_TIME,
|
||||
// Upload performance to Gauger
|
||||
PERF_TALER_MINTDB_CMD_GAUGER,
|
||||
|
||||
// Upload performance to Gauger
|
||||
CMD_GAUGER,
|
||||
// Start a database transaction
|
||||
PERF_TALER_MINTDB_CMD_START_TRANSACTION,
|
||||
|
||||
// Start a database transaction
|
||||
CMD_START_TRANSACTION,
|
||||
// End a database transaction
|
||||
PERF_TALER_MINTDB_CMD_COMMIT_TRANSACTION,
|
||||
|
||||
// End a database transaction
|
||||
CMD_COMMIT_TRANSACTION,
|
||||
// Insert a deposit into the database
|
||||
PERF_TALER_MINTDB_CMD_INSERT_DEPOSIT,
|
||||
|
||||
// Insert a deposit into the database
|
||||
CMD_INSERT_DEPOSIT,
|
||||
// Check if a deposit is in the database
|
||||
PERF_TALER_MINTDB_CMD_GET_DEPOSIT,
|
||||
|
||||
// Check if a deposit is in the database
|
||||
CMD_GET_DEPOSIT,
|
||||
// Saves random deposits from a loop
|
||||
PERF_TALER_MINTDB_CMD_SAVE_ARRAY,
|
||||
|
||||
// Saves random deposits from a loop
|
||||
CMD_SAVE_ARRAY,
|
||||
// Load deposits saved earlier
|
||||
PERF_TALER_MINTDB_CMD_LOAD_ARRAY,
|
||||
|
||||
// Load deposits saved earlyer
|
||||
CMD_LOAD_ARRAY,
|
||||
|
||||
} command;
|
||||
|
||||
const char *name; // label!
|
||||
|
||||
// Contains command specific data.
|
||||
union {
|
||||
struct {
|
||||
const int max_iterations;
|
||||
int curr_iteration;
|
||||
} loop;
|
||||
|
||||
struct {
|
||||
char loop_start[40];
|
||||
} end_loop;
|
||||
|
||||
struct {
|
||||
char start_time[40];
|
||||
char stop_time[40];
|
||||
|
||||
char description[40];
|
||||
} gauger;
|
||||
|
||||
struct {
|
||||
/**
|
||||
* Comment!
|
||||
*/
|
||||
unsigned int nb; // Number of deposits to save
|
||||
unsigned int index; // The number of deposits already saved
|
||||
char loop[40]; // The loop from which the data will be extracted
|
||||
char saved[40]; // The deposit saved
|
||||
enum PERF_TALER_MINTDB_TYPE saved_type;
|
||||
union NAME_IT_TOP_LEVEL {
|
||||
struct TALER_MINTDB_Deposit *deposit;
|
||||
struct timespec time;
|
||||
} *samples;
|
||||
} save_array;
|
||||
|
||||
struct {
|
||||
int nb; //the number of deposits to save
|
||||
char loop[40];
|
||||
char saved[40]; // The command where the deposit were saved
|
||||
enum PERF_TALER_MINTDB_TYPE loaded_type;
|
||||
unsigned int *permutation; // A permutation array to randomize the order the deposits are loaded in
|
||||
} load_array;
|
||||
|
||||
struct {
|
||||
char source[40];
|
||||
} get_deposit;
|
||||
} command;
|
||||
|
||||
|
||||
} details;
|
||||
union NAME_IT_TOP_LEVEL {
|
||||
struct TALER_MINTDB_Deposit *deposit;
|
||||
struct timespec time;
|
||||
} exposed;
|
||||
struct PERF_TALER_MINTDB_loop_details
|
||||
{
|
||||
// Maximum number of iteration in the loop
|
||||
const unsigned int max_iterations;
|
||||
int curr_iteration;
|
||||
};
|
||||
|
||||
int exposed_used;
|
||||
struct PERF_TALER_MINTDB_loop_end_details
|
||||
{
|
||||
/**
|
||||
* Label of the loop closed by the command
|
||||
*/
|
||||
const char *label_loop;
|
||||
};
|
||||
|
||||
/**
|
||||
* Details about the GAUGER command
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_gauger_details
|
||||
{
|
||||
/**
|
||||
* Label of the starting timestamp
|
||||
*/
|
||||
const char *label_start;
|
||||
/**
|
||||
* Label of the ending timestamp
|
||||
*/
|
||||
const char *label_stop;
|
||||
/**
|
||||
* Description of the metric, used in GAUGER
|
||||
*/
|
||||
const char *description;
|
||||
};
|
||||
|
||||
/**
|
||||
* Contains details about a command
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_save_array_details
|
||||
{
|
||||
/**
|
||||
* Number of items to save
|
||||
*/
|
||||
unsigned int nb_saved;
|
||||
/**
|
||||
* Number of items already saved
|
||||
*/
|
||||
unsigned int index;
|
||||
/**
|
||||
* Label of the loop it is attached to
|
||||
*/
|
||||
const char *label_loop;
|
||||
/**
|
||||
* Label of the command exposing the item
|
||||
*/
|
||||
const char *label_save;
|
||||
/**
|
||||
* Type of data saved
|
||||
*/
|
||||
enum PERF_TALER_MINTDB_TYPE type_saved;
|
||||
/**
|
||||
* Array of data saved
|
||||
*/
|
||||
union PERF_TALER_MINTDB_Data *data_saved;
|
||||
};
|
||||
|
||||
struct PERF_TALER_MINTDB_load_array_details
|
||||
{
|
||||
/**
|
||||
* TODO Remove references to nb and use the link to the loop to initialize
|
||||
*/
|
||||
int nb;
|
||||
/**
|
||||
* The loop in which the comand is located
|
||||
*/
|
||||
const char *label_loop;
|
||||
/**
|
||||
* Label of the command where the items were saved
|
||||
*/
|
||||
const char *label_saved;
|
||||
/**
|
||||
* 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
|
||||
};
|
||||
|
||||
struct PERF_TALER_MINTDB_get_deposit_details
|
||||
{
|
||||
const char *source;
|
||||
};
|
||||
|
||||
union PERF_TALER_MINTDB_Details
|
||||
{
|
||||
struct PERF_TALER_MINTDB_LOOP_DETAILS loop,
|
||||
struct PERF_TALER_MINTDB_LOOP_END_DETAILS end_loop,
|
||||
struct PERF_TALER_MINTDB_GAUGER_DETAILS gauger,
|
||||
struct PERF_TALER_MINTDB_SAVE_ARRAY save_array,
|
||||
struct PERF_TALER_MINTDB_LOAD_ARRAY_DETAILS load_array,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Command to be interpreted.
|
||||
*/
|
||||
struct PERF_TALER_MINTDB_Cmd
|
||||
{
|
||||
enum PERF_TALER_MINTDB_CMD_Name command;
|
||||
|
||||
/**
|
||||
* Label to refer to the command
|
||||
*/
|
||||
const char *label;
|
||||
|
||||
/**
|
||||
* Command specific data
|
||||
*/
|
||||
union PERF_TALER_MINTDB_Details details;
|
||||
|
||||
/**
|
||||
* Type of the data exposed
|
||||
*/
|
||||
enum PERF_TALER_MINTDB_Type exposed_type;
|
||||
|
||||
/**
|
||||
* Data easily accessible
|
||||
*/
|
||||
union PERF_TALER_MINTDB_Data exposed;
|
||||
|
||||
int exposed_saved;
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
PERF_TALER_MINTDB_interprete(
|
||||
PERF_TALER_MINTDB_interpret(
|
||||
struct TALER_MINTDB_Plugin *db_plugin,
|
||||
struct TALER_MINTDB_Session *session, // add START_SESSION CMD
|
||||
struct PERF_TALER_MINTDB_CMD cmd[]);
|
||||
|
@ -1,3 +1,23 @@
|
||||
/*
|
||||
This file is part of TALER
|
||||
Copyright (C) 2014, 2015 Christian Grothoff (and other contributing authors)
|
||||
|
||||
TALER is free software; you can redistribute it and/or modify it under the
|
||||
terms of the GNU General Public License as published by the Free Software
|
||||
Foundation; either version 3, or (at your option) any later version.
|
||||
|
||||
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.
|
||||
|
||||
You should have received a copy of the GNU General Public License along with
|
||||
TALER; see the file COPYING. If not, If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
/**
|
||||
* @file mintdb/perf_taler_mintdb_values.h
|
||||
* @brief Values for tweaking the performance analysis
|
||||
* @author Nicolas Fournier
|
||||
*/
|
||||
#ifndef __PERF_TALER_MINTDB__VALUES_H__
|
||||
#define __PERF_TALER_MINTDB__VALUES_H__
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user