-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstats.h
58 lines (46 loc) · 1.53 KB
/
stats.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* Paweł Foremski <[email protected]> 2011
* IITiS PAN Gliwice
*/
#ifndef _STAT_H_
#define _STAT_H_
#include "generator.h"
/** Inititalize mgstats data structures, etc. */
void mgstats_init(struct mg *mg);
/** Starts statistics system, periodic writes, etc.
* @note requires mg->origin */
void mgstats_start(struct mg *mg);
/** Register statistics aggregation and writing process
* @param handler callback function which does aggregation
* @param arg handler argument
* @param dir optional directory under main stats dir
* @param file file name for statistics (eg. stats.txt)
* @param ... names and order of columns (ie. keys in stats database to export),
* last name must be NULL
*/
void mgstats_writer_add(struct mg *mg,
stats_writer_handler_t handler, void *arg,
const char *dir, const char *file, ...);
/*****/
/** Initialize a stats database
* @param mm target memory
*/
stats *stats_create(mmatic *mm);
/** Increase counter
* @param name stat name
* @param num increase amount
*/
void stats_countN(stats *stats, const char *name, uint32_t num);
/** Increase counter by 1 */
#define stats_count(ut, name) stats_countN(ut, name, 1)
/** Set gauge level
* @param name stat name
* @param val new value for mean
*/
void stats_mean(stats *stats, const char *name, int val);
/** Aggregate statistics
* @param src source stats db, after call counters will be zeroed
* @param dst already existing, destination stats db
*/
void stats_aggregate(stats *dst, stats *src);
#endif