My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions
rt_stats.h File Reference

Collecting statistics within the runtime. More...

#include "stats.h"
#include <stdbool.h>

Go to the source code of this file.

Functions

int remove_stat_item (enum stat_id stat_id, unsigned int item_id)
 Un-registers an item so it can no longer have statistics registered, and will not be reported to the global controller. More...
 
int init_stat_item (enum stat_id stat_id, unsigned int item_id)
 Initializes a new stat item so it can have stats registered and can be reported to the global controller. More...
 
int init_statistics ()
 Initializes the entire stats module. More...
 
void finalize_statistics (char *statlog)
 Writes the statistics to statlog if provided, and frees assocated structure. More...
 
int record_start_time (enum stat_id stat_id, unsigned int item_id)
 Starts a measurement of elapsed time. More...
 
int record_end_time (enum stat_id stat_id, unsigned int item_id)
 Records the elapsed time since the previous call to record_start_time. More...
 
int increment_stat (enum stat_id stat_id, unsigned int item_id, double value)
 Increments the given statistic by the provided value. More...
 
int record_stat (enum stat_id stat_id, unsigned int item_id, double stat, bool relog)
 Records a statistic in the statlog. More...
 
double get_last_stat (enum stat_id stat_id, unsigned int item_id)
 Returns the last statistic recorded. More...
 
struct stat_sampleget_stat_samples (enum stat_id stat_id, struct timespec *time, int *n_sample_out)
 Samples the statistic with the provided stat_id. More...
 

Detailed Description

Collecting statistics within the runtime.

Definition in file rt_stats.h.

Function Documentation

void finalize_statistics ( char *  statlog)

Writes the statistics to statlog if provided, and frees assocated structure.

Parameters
statlogLog file to dump statistics to or NULL if N/A

Definition at line 822 of file rt_stats.c.

double get_last_stat ( enum stat_id  stat_id,
unsigned int  item_id 
)

Returns the last statistic recorded.

Definition at line 466 of file rt_stats.c.

struct stat_sample* get_stat_samples ( enum stat_id  stat_id,
struct timespec *  time,
int *  n_sample_out 
)

Samples the statistic with the provided stat_id.

Parameters
stat_idthe ID of the stat_type to sample
timeThe time at which the samples should be taken
n_samples_outOutput argument, stores the number of samples acquired
Returns
The statically-allocated stat sample (does not need to be freed)

Definition at line 634 of file rt_stats.c.

int increment_stat ( enum stat_id  stat_id,
unsigned int  item_id,
double  value 
)

Increments the given statistic by the provided value.

Parameters
stat_idID for the stat being logged
item_idID for the item to which the stat refers (must be registered!)
valueThe amount to add to the given stat
Returns
0 on success, -1 on error

Definition at line 389 of file rt_stats.c.

int init_stat_item ( enum stat_id stat_id  ,
unsigned int  item_id 
)

Initializes a new stat item so it can have stats registered and can be reported to the global controller.

Initializes a new stat item so it can have stats registered and can be reported to the global controller.

(e.g. initializing MSU_QUEUE_LEN for item N, corresponding to msu # N)

Parameters
stat_idID of the statistic type to be logged
item_idID of the item to be logged

Definition at line 719 of file rt_stats.c.

int init_statistics ( )

Initializes the entire stats module.

MUST BE CALLED before runtime starts

Definition at line 783 of file rt_stats.c.

int record_end_time ( enum stat_id  stat_id,
unsigned int  item_id 
)

Records the elapsed time since the previous call to record_start_time.

Parameters
stat_idID for stat being logged
item_idID for item within the statistic

Definition at line 355 of file rt_stats.c.

int record_start_time ( enum stat_id  stat_id,
unsigned int  item_id 
)

Starts a measurement of elapsed time.

Not added to the log until a call to record_end_time

Parameters
stat_idID for stat type being logged
item_idID for the item to which the stat refers
Returns
0 on success, -1 on error

Definition at line 320 of file rt_stats.c.

int record_stat ( enum stat_id  stat_id,
unsigned int  item_id,
double  stat,
bool  relog 
)

Records a statistic in the statlog.

Parameters
stat_idID for stat being logged
item_idID for item to which stat refers (must be registered!)
statStatistic to record
relogWhether to log statistic if it matches the previously logged stat
Returns
0 on success, -1 on error

Definition at line 426 of file rt_stats.c.

int remove_stat_item ( enum stat_id  stat_id,
unsigned int  item_id 
)

Un-registers an item so it can no longer have statistics registered, and will not be reported to the global controller.

Definition at line 683 of file rt_stats.c.