36 for (i = 0; i < n_samples; i++) {
37 int index = start_index - i;
40 if ( timeseries->
time[index].tv_sec < 0 ){
44 sum += timeseries->
data[index];
49 return sum / (double)gathered;
61 for (
int i=0; i<input_size; i++) {
63 if (input[i].
time.tv_sec == 0 && input[i].
time.tv_nsec == 0) {
87 buff += sprintf(buff,
"TIME: ");
91 double time = timeseries->
time[index].tv_sec +
92 ((double)timeseries->
time[index].tv_nsec * 1e-9);
93 buff += sprintf(buff,
"| %9.4f ", time);
96 buff += sprintf(buff,
"| ... ");
99 int index = (timeseries->
write_index + i) % RRDB_ENTRIES;
100 double time = timeseries->
time[index].tv_sec +
101 ((double)timeseries->
time[index].tv_nsec * 1e-9);
102 buff += sprintf(buff,
"| %9.4f ", time);
105 buff += sprintf(buff,
"\nDATA: ");
107 int index = (timeseries->
write_index + i) % RRDB_ENTRIES;
108 buff += sprintf(buff,
"| %9d ", (
int)timeseries->
data[index]);
110 buff += sprintf(buff,
"| ... ");
112 for (
int i=RRDB_ENTRIES-PRINT_LEN; i<
RRDB_ENTRIES; i++){
113 int index = (timeseries->
write_index + i) % RRDB_ENTRIES;
114 buff += sprintf(buff,
"| %9d ", (
int)timeseries->
data[index]);
116 buff += sprintf(buff,
"\n");
double average_n(struct timed_rrdb *timeseries, int n_samples)
timeseries.c
Round-robin database (circular buffer) for storing timeseries data.
#define PRINT_LEN
The length of the begnning and end of the timeseries that's printed when print_timeseries() is called...
double data[240]
The statistics.
Logging of status messages to the terminal.
Functions for the sending and receiving of statistics between ctrl and runtime.
int write_index
Offset into the rrdb at which writing has occurred.
int append_to_timeseries(struct timed_stat *input, int input_size, struct timed_rrdb *timeseries)
Appends a number of timed statistics to a timeseries.
#define RRDB_ENTRIES
timeseries.h
void print_timeseries(struct timed_rrdb *timeseries)
Prints the beginning and end of a timeseries.
Interfaces for the creation and modification of the data-flow-graph and and general description of th...
Holds a single timestamped value.
struct timespec time[240]
The time at which the stats were gathered.