GNUnet 0.22.2
gnunet-fs-profiler.c File Reference

tool to benchmark/profile file-sharing More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "gnunet_testbed_service.h"
Include dependency graph for gnunet-fs-profiler.c:

Go to the source code of this file.

Functions

static void shutdown_task (void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
 Function called after we've collected the statistics. More...
 
static int process_stats (void *cls, const struct GNUNET_TESTBED_Peer *peer, const char *subsystem, const char *name, uint64_t value, int is_persistent)
 Callback function to process statistic values from all peers. More...
 
static void terminate_task (void *cls)
 Task run on shutdown to terminate. More...
 
static void timeout_task (void *cls)
 Task run on timeout to terminate. More...
 
static void test_master (void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded, unsigned int links_failed)
 Signature of a main function for a testcase. More...
 
static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
 Main function that will be run by the scheduler. More...
 
int main (int argc, char *const *argv)
 Program to run a file-sharing testbed. More...
 

Variables

static int ret
 Final status code. More...
 
static char * host_filename
 Data file with the hosts for the testbed. More...
 
static unsigned int num_peers
 Number of peers to run in the experiment. More...
 
static struct GNUNET_TIME_Relative timeout
 After how long do we abort the test? More...
 
static struct GNUNET_SCHEDULER_Taskterminate_taskid
 Handle to the task run during termination. More...
 

Detailed Description

tool to benchmark/profile file-sharing

Author
Christian Grothoff

Definition in file gnunet-fs-profiler.c.

Function Documentation

◆ shutdown_task()

static void shutdown_task ( void *  cls,
struct GNUNET_TESTBED_Operation *  op,
const char *  emsg 
)
static

Function called after we've collected the statistics.

Parameters
clsNULL
opthe operation that has been finished
emsgerror message in case the operation has failed; will be NULL if operation has executed successfully.

Definition at line 65 of file gnunet-fs-profiler.c.

68{
69 if (NULL != emsg)
70 fprintf (stderr,
71 "Error collecting statistics: %s\n",
72 emsg);
74}
void GNUNET_SCHEDULER_shutdown(void)
Request the shutdown of a scheduler.
Definition: scheduler.c:567

References GNUNET_SCHEDULER_shutdown().

Referenced by terminate_task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ process_stats()

static int process_stats ( void *  cls,
const struct GNUNET_TESTBED_Peer *  peer,
const char *  subsystem,
const char *  name,
uint64_t  value,
int  is_persistent 
)
static

Callback function to process statistic values from all peers.

Prints them out.

Parameters
clsclosure
peerthe peer the statistic belong to
subsystemname of subsystem that created the statistic
namethe name of the datum
valuethe current value
is_persistentGNUNET_YES if the value is persistent, GNUNET_NO if not
Returns
GNUNET_OK to continue, GNUNET_SYSERR to abort iteration

Definition at line 90 of file gnunet-fs-profiler.c.

96{
97 fprintf (stdout,
98 "%p-%s: %s = %llu\n",
99 peer,
100 subsystem,
101 name,
102 (unsigned long long) value);
103 return GNUNET_OK;
104}
static char * name
Name (label) of the records to list.
static char * value
Value of the record to add/remove.
static char * subsystem
Set to subsystem that we're going to get stats for (or NULL for all).
@ GNUNET_OK

References GNUNET_OK, name, subsystem, and value.

Referenced by terminate_task().

Here is the caller graph for this function:

◆ terminate_task()

static void terminate_task ( void *  cls)
static

Task run on shutdown to terminate.

Triggers printing out all statistics.

Parameters
clsNULL

Definition at line 114 of file gnunet-fs-profiler.c.

115{
116 if (NULL != terminate_taskid)
117 {
119 terminate_taskid = NULL;
120 }
121 GNUNET_TESTBED_get_statistics (0, NULL,
122 NULL, NULL,
125 NULL);
126}
static struct GNUNET_SCHEDULER_Task * terminate_taskid
Handle to the task run during termination.
static int process_stats(void *cls, const struct GNUNET_TESTBED_Peer *peer, const char *subsystem, const char *name, uint64_t value, int is_persistent)
Callback function to process statistic values from all peers.
static void shutdown_task(void *cls, struct GNUNET_TESTBED_Operation *op, const char *emsg)
Function called after we've collected the statistics.
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:980

References GNUNET_SCHEDULER_cancel(), process_stats(), shutdown_task(), and terminate_taskid.

Referenced by test_master().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ timeout_task()

static void timeout_task ( void *  cls)
static

Task run on timeout to terminate.

Triggers printing out all statistics.

Parameters
clsNULL

Definition at line 136 of file gnunet-fs-profiler.c.

137{
138 terminate_taskid = NULL;
140}

References GNUNET_SCHEDULER_shutdown(), and terminate_taskid.

Referenced by test_master().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_master()

static void test_master ( void *  cls,
struct GNUNET_TESTBED_RunHandle *  h,
unsigned int  num_peers,
struct GNUNET_TESTBED_Peer **  peers,
unsigned int  links_succeeded,
unsigned int  links_failed 
)
static

Signature of a main function for a testcase.

Parameters
clsclosure
hthe run handle
num_peersnumber of peers in 'peers'
peershandle to peers run in the testbed
links_succeededthe number of overlay link connection attempts that succeeded
links_failedthe number of overlay link connection attempts that failed

Definition at line 156 of file gnunet-fs-profiler.c.

162{
163 // const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
164 // FIXME: enable clients to signal 'completion' before timeout;
165 // in that case, run the 'terminate_task' "immediately"
166
167 if (0 != timeout.rel_value_us)
170 NULL);
172 NULL);
173}
static void terminate_task(void *cls)
Task run on shutdown to terminate.
static void timeout_task(void *cls)
Task run on timeout to terminate.
static struct GNUNET_TIME_Relative timeout
After how long do we abort the test?
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_shutdown(GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run on shutdown, that is when a CTRL-C signal is received,...
Definition: scheduler.c:1339
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1277
uint64_t rel_value_us
The actual value.

References GNUNET_SCHEDULER_add_delayed(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_TIME_Relative::rel_value_us, terminate_task(), terminate_taskid, timeout, and timeout_task().

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

static void run ( void *  cls,
char *const *  args,
const char *  cfgfile,
const struct GNUNET_CONFIGURATION_Handle cfg 
)
static

Main function that will be run by the scheduler.

Parameters
clsclosure
argsremaining command-line arguments
cfgfilename of the configuration file used (for saving, can be NULL!)
cfgconfiguration

Definition at line 185 of file gnunet-fs-profiler.c.

187{
188 GNUNET_TESTBED_run (host_filename,
189 cfg,
190 num_peers,
191 0, NULL, NULL,
192 &test_master, (void *) cfg);
193}
static struct GNUNET_CONFIGURATION_Handle * cfg
Our configuration.
Definition: gnunet-arm.c:108
static void test_master(void *cls, struct GNUNET_TESTBED_RunHandle *h, unsigned int num_peers, struct GNUNET_TESTBED_Peer **peers, unsigned int links_succeeded, unsigned int links_failed)
Signature of a main function for a testcase.
static char * host_filename
Data file with the hosts for the testbed.
static unsigned int num_peers
Number of peers to run in the experiment.

References cfg, host_filename, num_peers, and test_master().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *const *  argv 
)

Program to run a file-sharing testbed.

Parameters
argcnumber of arguments from the command line
argvcommand line arguments
Returns
0 ok, 1 on error

Definition at line 204 of file gnunet-fs-profiler.c.

205{
208 "num-peers",
209 "COUNT",
211 "run the experiment with COUNT peers"),
212 &num_peers),
213
215 "hosts",
216 "HOSTFILE",
218 "specifies name of a file with the HOSTS the testbed should use"),
220
222 "timeout",
223 "DELAY",
225 "automatically terminate experiment after DELAY"),
226 &timeout),
227
229 };
230
231 ret = (GNUNET_OK ==
232 GNUNET_PROGRAM_run (argc, argv, "gnunet-fs-profiler",
234 "run a testbed to measure file-sharing performance"),
235 options, &run,
236 NULL)) ? ret : 1;
237 return ret;
238}
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_OPTION_END
Definition: 002.c:13
struct GNUNET_GETOPT_CommandLineOption options[]
Definition: 002.c:5
#define gettext_noop(String)
Definition: gettext.h:74
static int ret
Final status code.
static void run(void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg)
Main function that will be run by the scheduler.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint(char shortName, const char *name, const char *argumentHelp, const char *description, unsigned int *val)
Allow user to specify an unsigned int.
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time(char shortName, const char *name, const char *argumentHelp, const char *description, struct GNUNET_TIME_Relative *val)
Allow user to specify a struct GNUNET_TIME_Relative (using human-readable "fancy" time).
struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_string(char shortName, const char *name, const char *argumentHelp, const char *description, char **str)
Allow user to specify a string.
enum GNUNET_GenericReturnValue GNUNET_PROGRAM_run(const struct GNUNET_OS_ProjectData *pd, int argc, char *const *argv, const char *binaryName, const char *binaryHelp, const struct GNUNET_GETOPT_CommandLineOption *options, GNUNET_PROGRAM_Main task, void *task_cls)
Run a standard GNUnet command startup sequence (initialize loggers and configuration,...
Definition: program.c:407
Definition of a command line option.

References gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_relative_time(), GNUNET_GETOPT_option_string(), GNUNET_GETOPT_option_uint(), GNUNET_OK, GNUNET_PROGRAM_run(), host_filename, num_peers, options, ret, run(), and timeout.

Here is the call graph for this function:

Variable Documentation

◆ ret

int ret
static

Final status code.

Definition at line 33 of file gnunet-fs-profiler.c.

Referenced by main().

◆ host_filename

char* host_filename
static

Data file with the hosts for the testbed.

Definition at line 38 of file gnunet-fs-profiler.c.

Referenced by main(), and run().

◆ num_peers

unsigned int num_peers
static

Number of peers to run in the experiment.

Definition at line 43 of file gnunet-fs-profiler.c.

Referenced by main(), and run().

◆ timeout

struct GNUNET_TIME_Relative timeout
static

After how long do we abort the test?

Definition at line 48 of file gnunet-fs-profiler.c.

Referenced by main(), and test_master().

◆ terminate_taskid

struct GNUNET_SCHEDULER_Task* terminate_taskid
static

Handle to the task run during termination.

Definition at line 53 of file gnunet-fs-profiler.c.

Referenced by terminate_task(), test_master(), and timeout_task().