blob: ae8ccd7227cfa2d3f0a2e74ab06efab814ac3bfd [file] [log] [blame]
Xiao Guangrong0007ece2012-09-17 16:31:14 +08001#ifndef __PERF_STATS_H
2#define __PERF_STATS_H
3
4#include "types.h"
5
6struct stats
7{
8 double n, mean, M2;
David Ahernffe4f3c2013-08-02 14:05:40 -06009 u64 max, min;
Xiao Guangrong0007ece2012-09-17 16:31:14 +080010};
11
12void update_stats(struct stats *stats, u64 val);
13double avg_stats(struct stats *stats);
14double stddev_stats(struct stats *stats);
15double rel_stddev_stats(double stddev, double avg);
16
David Ahernffe4f3c2013-08-02 14:05:40 -060017static inline void init_stats(struct stats *stats)
18{
19 stats->n = 0.0;
20 stats->mean = 0.0;
21 stats->M2 = 0.0;
22 stats->min = (u64) -1;
23 stats->max = 0;
24}
Xiao Guangrong0007ece2012-09-17 16:31:14 +080025#endif