GNUnet 0.22.2
testing_api_cmd_stat.c File Reference

command(s) to get performance statistics on other commands More...

#include "platform.h"
#include "gnunet_testing_lib.h"
#include "testing_api_cmd_batch.h"
Include dependency graph for testing_api_cmd_stat.c:

Go to the source code of this file.

Functions

static void stat_run (void *cls, struct GNUNET_TESTING_Interpreter *is)
 Run a "stat" CMD. More...
 
static void stat_cmd (struct GNUNET_TESTING_Timer *timings, const struct GNUNET_TESTING_Command *cmd)
 Add the time cmd took to the respective duration in timings. More...
 
static void do_stat (void *cls, const struct GNUNET_TESTING_Command *cmd)
 Obtain statistics for timings of cmd. More...
 
struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stat (const char *label, struct GNUNET_TESTING_Timer *timers)
 Obtain performance data from the interpreter. More...
 

Detailed Description

command(s) to get performance statistics on other commands

Author
Christian Grothoff

Definition in file testing_api_cmd_stat.c.

Function Documentation

◆ stat_run()

static void stat_run ( void *  cls,
struct GNUNET_TESTING_Interpreter is 
)
static

Run a "stat" CMD.

Parameters
clsclosure.
isthe interpreter state.
clsclosure.
cmdthe command being run.
isthe interpreter state.

Definition at line 137 of file testing_api_cmd_stat.c.

139{
140 struct GNUNET_TESTING_Timer *timings = cls;
141
143 true,
144 &do_stat,
145 timings);
146}
static struct GNUNET_TESTING_Interpreter * is
void GNUNET_TESTING_interpreter_commands_iterate(struct GNUNET_TESTING_Interpreter *is, bool asc, GNUNET_TESTING_CommandIterator cb, void *cb_cls)
Iterates over all of the top-level commands of an interpreter.
Performance counter.
static void do_stat(void *cls, const struct GNUNET_TESTING_Command *cmd)
Obtain statistics for timings of cmd.

References do_stat(), GNUNET_TESTING_interpreter_commands_iterate(), and is.

Referenced by GNUNET_TESTING_cmd_stat(), and stat_cmd().

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

◆ stat_cmd()

static void stat_cmd ( struct GNUNET_TESTING_Timer timings,
const struct GNUNET_TESTING_Command cmd 
)
static

Add the time cmd took to the respective duration in timings.

Parameters
timingswhere to add up times
cmdcommand to evaluate

Definition at line 46 of file testing_api_cmd_stat.c.

48{
50 struct GNUNET_TIME_Relative lat;
51
53 >,
54 cmd->finish_time))
55 {
56 /* This is a problem, except of course for
57 this command itself, as we clearly did not yet
58 finish... */
59 if (cmd->run != &stat_run)
60 {
62 "Bad timings for `%s'\n",
63 cmd->label.value);
64 GNUNET_break (0);
65 }
66 return;
67 }
69 cmd->finish_time);
71 cmd->finish_time);
72 for (unsigned int i = 0;
73 NULL != timings[i].prefix;
74 i++)
75 {
76 if (0 == strncmp (timings[i].prefix,
77 cmd->label.value,
78 strlen (timings[i].prefix)))
79 {
80 timings[i].total_duration
82 timings[i].total_duration);
83 timings[i].success_latency
85 timings[i].success_latency);
86 timings[i].num_commands++;
87 timings[i].num_retries += cmd->num_tries;
88 break;
89 }
90 }
91}
static int prefix
If printing the value of PREFIX has been requested.
Definition: gnunet-config.c:65
static struct GNUNET_TIME_Relative duration
Option '-d': duration of the mapping.
Definition: gnunet-vpn.c:90
#define GNUNET_log(kind,...)
#define GNUNET_break(cond)
Use this for internal assertion violations that are not fatal (can be handled) but should not occur.
@ GNUNET_ERROR_TYPE_ERROR
struct GNUNET_TIME_Relative GNUNET_TIME_relative_add(struct GNUNET_TIME_Relative a1, struct GNUNET_TIME_Relative a2)
Add relative times together.
Definition: time.c:587
#define GNUNET_TIME_absolute_cmp(t1, op, t2)
Compare two absolute times.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_difference(struct GNUNET_TIME_Absolute start, struct GNUNET_TIME_Absolute end)
Compute the time difference between the given start and end times.
Definition: time.c:423
struct GNUNET_TIME_Absolute finish_time
When did the execution of this command finish?
struct GNUNET_TESTING_CommandLabel label
Label for the command.
struct GNUNET_TIME_Absolute last_req_time
When did we start the last run of this command? Delta to finish_time gives the latency for the last s...
GNUNET_TESTING_CommandRunRoutine run
Runs the command.
unsigned int num_tries
How often did we try to execute this command? (In case it is a request that is repated....
struct GNUNET_TIME_Absolute start_time
When did the execution of this command start?
unsigned int num_commands
Number of commands summed up.
const char * prefix
For which type of commands.
struct GNUNET_TIME_Relative total_duration
Total time spend in all commands of this type.
unsigned int num_retries
Number of retries summed up.
struct GNUNET_TIME_Relative success_latency
Total time spend waiting for the successful execution in all commands of this type.
Time for relative time used by GNUnet, in microseconds.
static void stat_run(void *cls, struct GNUNET_TESTING_Interpreter *is)
Run a "stat" CMD.

References duration, GNUNET_TESTING_Command::finish_time, GNUNET_break, GNUNET_ERROR_TYPE_ERROR, GNUNET_log, GNUNET_TIME_absolute_cmp, GNUNET_TIME_absolute_get_difference(), GNUNET_TIME_relative_add(), GNUNET_TESTING_Command::label, GNUNET_TESTING_Command::last_req_time, GNUNET_TESTING_Timer::num_commands, GNUNET_TESTING_Timer::num_retries, GNUNET_TESTING_Command::num_tries, prefix, GNUNET_TESTING_Timer::prefix, GNUNET_TESTING_Command::run, GNUNET_TESTING_Command::start_time, stat_run(), GNUNET_TESTING_Timer::success_latency, GNUNET_TESTING_Timer::total_duration, and GNUNET_TESTING_CommandLabel::value.

Referenced by do_stat().

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

◆ do_stat()

static void do_stat ( void *  cls,
const struct GNUNET_TESTING_Command cmd 
)
static

Obtain statistics for timings of cmd.

Parameters
[in,out]clswhat timings to get
cmdcommand to process

Definition at line 101 of file testing_api_cmd_stat.c.

103{
104 struct GNUNET_TESTING_Timer *timings = cls;
105
107 {
108 struct GNUNET_TESTING_Command **bcmd;
109
110 if (GNUNET_OK !=
112 &bcmd))
113 {
114 GNUNET_break (0);
115 return;
116 }
117 for (unsigned int j = 0;
118 NULL != (*bcmd)[j].run;
119 j++)
120 do_stat (timings,
121 &(*bcmd)[j]);
122 return;
123 }
124 stat_cmd (timings,
125 cmd);
126}
enum GNUNET_GenericReturnValue GNUNET_TESTING_get_trait_batch_cmds(const struct GNUNET_TESTING_Command *cmd, struct GNUNET_TESTING_Command ***ret)
@ GNUNET_OK
A command to be run by the interpreter.
bool GNUNET_TESTING_cmd_is_batch_(const struct GNUNET_TESTING_Command *cmd)
Test if this command is a batch command.
static void stat_cmd(struct GNUNET_TESTING_Timer *timings, const struct GNUNET_TESTING_Command *cmd)
Add the time cmd took to the respective duration in timings.

References do_stat(), GNUNET_break, GNUNET_OK, GNUNET_TESTING_cmd_is_batch_(), GNUNET_TESTING_get_trait_batch_cmds(), and stat_cmd().

Referenced by do_stat(), and stat_run().

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

◆ GNUNET_TESTING_cmd_stat()

struct GNUNET_TESTING_Command GNUNET_TESTING_cmd_stat ( const char *  label,
struct GNUNET_TESTING_Timer timers 
)

Obtain performance data from the interpreter.

Parameters
labelcommand label.
[in,out]timersNULL-prefix terminated array that specifies what commands (by label) to obtain runtimes for
Returns
the command

Definition at line 150 of file testing_api_cmd_stat.c.

152{
153 return GNUNET_TESTING_command_new ((void *) timers,
154 label,
155 &stat_run,
156 NULL,
157 NULL);
158}
#define GNUNET_TESTING_command_new(cls, label, run, cleanup, traits)
Create a new command.

References GNUNET_TESTING_command_new, and stat_run().

Here is the call graph for this function: