Xiao Guangrong | 0007ece | 2012-09-17 16:31:14 +0800 | [diff] [blame] | 1 | #ifndef __PERF_STATS_H |
| 2 | #define __PERF_STATS_H |
| 3 | |
Borislav Petkov | d944c4e | 2014-04-25 21:31:02 +0200 | [diff] [blame] | 4 | #include <linux/types.h> |
Xiao Guangrong | 0007ece | 2012-09-17 16:31:14 +0800 | [diff] [blame] | 5 | |
| 6 | struct stats |
| 7 | { |
| 8 | double n, mean, M2; |
David Ahern | ffe4f3c | 2013-08-02 14:05:40 -0600 | [diff] [blame] | 9 | u64 max, min; |
Xiao Guangrong | 0007ece | 2012-09-17 16:31:14 +0800 | [diff] [blame] | 10 | }; |
| 11 | |
| 12 | void update_stats(struct stats *stats, u64 val); |
| 13 | double avg_stats(struct stats *stats); |
| 14 | double stddev_stats(struct stats *stats); |
| 15 | double rel_stddev_stats(double stddev, double avg); |
| 16 | |
David Ahern | ffe4f3c | 2013-08-02 14:05:40 -0600 | [diff] [blame] | 17 | static 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 Guangrong | 0007ece | 2012-09-17 16:31:14 +0800 | [diff] [blame] | 25 | #endif |