1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00
VILLASnode/include/villas/stats.h

95 lines
2.7 KiB
C
Raw Permalink Normal View History

/** Statistic collection.
*
* @file
* @author Steffen Vogel <stvogel@eonerc.rwth-aachen.de>
2017-04-27 13:08:17 +02:00
* @copyright 2017, Institute for Automation of Complex Power Systems, EONERC
* @license GNU General Public License (version 3)
*
* VILLASnode
*
* This program 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 of the License, or
* any later version.
*
2017-04-27 13:08:17 +02:00
* This program 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.
*
2017-04-27 13:08:17 +02:00
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************************/
2018-06-29 08:37:37 +02:00
#pragma once
#include <stdint.h>
#include <jansson.h>
#include <villas/hist.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Forward declarations */
struct sample;
struct node;
enum stats_format {
STATS_FORMAT_HUMAN,
STATS_FORMAT_JSON,
STATS_FORMAT_MATLAB
};
enum stats_id {
2018-06-29 08:37:14 +02:00
STATS_SKIPPED, /**< Counter for skipped samples due to hooks. */
STATS_TIME, /**< The processing time per sample within VILLAsnode. */
STATS_REORDERED, /**< Counter for reordered samples. */
STATS_GAP_SAMPLE, /**< Histogram for inter sample timestamps (as sent by remote). */
STATS_GAP_RECEIVED, /**< Histogram for inter sample arrival time (as seen by this instance). */
STATS_OWD, /**< Histogram for one-way-delay (OWD) of received samples. */
STATS_COUNT /**< Just here to have an updated number of statistics. */
};
struct stats_delta {
double values[STATS_COUNT];
2018-06-29 08:37:14 +02:00
int update; /**< Bitmask of stats_id. Only those which are masked will be updated */
};
struct stats {
struct hist histograms[STATS_COUNT];
2016-11-20 13:01:17 -05:00
struct stats_delta *delta;
};
2017-07-28 18:11:52 +02:00
int stats_lookup_format(const char *str);
int stats_init(struct stats *s, int buckets, int warmup);
int stats_destroy(struct stats *s);
void stats_update(struct stats *s, enum stats_id id, double val);
void stats_collect(struct stats *s, struct sample *smps[], size_t *cnt);
int stats_commit(struct stats *s);
2018-06-29 08:37:14 +02:00
json_t * stats_json(struct stats *s);
void stats_reset(struct stats *s);
void stats_print_header(enum stats_format fmt);
void stats_print_footer(enum stats_format fmt);
void stats_print_periodic(struct stats *s, FILE *f, enum stats_format fmt, int verbose, struct node *p);
void stats_print(struct stats *s, FILE *f, enum stats_format fmt, int verbose);
2017-03-29 04:20:26 +02:00
enum stats_id stats_lookup_id(const char *name);
#ifdef __cplusplus
}
#endif