]>
git.ipfire.org Git - thirdparty/rng-tools.git/blob - stats.h
2 * stats.h -- Statistics helpers
4 * Copyright (C) 2004 Henrique M. Holschuh <hmh@debian.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
29 uint64_t max
; /* Highest value seen */
30 uint64_t min
; /* Lowest value seen */
31 uint64_t num_samples
; /* Number of samples */
32 uint64_t sum
; /* Sum of all samples */
35 /* Sets a prefix for all stat dumps. Maximum length is 19 chars */
36 extern void set_stat_prefix(const char* prefix
);
38 /* Computes elapsed time in microseconds */
39 extern uint64_t elapsed_time(struct timeval
*start
,
40 struct timeval
*stop
);
42 /* Updates min-max stat */
43 extern void update_stat(struct rng_stat
*stat
, uint64_t value
);
45 /* Updates min-max microseconds timer stat */
46 #define update_usectimer_stat(STAT, START, STOP) \
47 update_stat(STAT, elapsed_time(START, STOP))
50 * The following functions format a stat dump on buf, and
51 * return a pointer to the start of buf
54 /* Dump simple counter */
55 extern char *dump_stat_counter(char *buf
, int size
,
56 const char *msg
, uint64_t value
);
58 /* Dump min-max time stat */
59 extern char *dump_stat_stat(char *buf
, int size
,
60 const char *msg
, const char *unit
,
61 struct rng_stat
*stat
);
64 * Dump min-max speed stat, base time unit is a microsecond
66 extern char *dump_stat_bw(char *buf
, int size
,
67 const char *msg
, const char *unit
,
68 struct rng_stat
*stat
,