blob: 3df529bd077432858149130eefae1c99e9098115 [file] [log] [blame]
Xiao Guangrong0007ece2012-09-17 16:31:14 +08001#ifndef __PERF_STATS_H
2#define __PERF_STATS_H
3
Borislav Petkovd944c4e2014-04-25 21:31:02 +02004#include <linux/types.h>
Xiao Guangrong0007ece2012-09-17 16:31:14 +08005
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
Jiri Olsae2f56da2015-06-04 15:50:55 +020012enum perf_stat_evsel_id {
13 PERF_STAT_EVSEL_ID__NONE = 0,
Jiri Olsa4c358d52015-06-03 16:25:52 +020014 PERF_STAT_EVSEL_ID__CYCLES_IN_TX,
15 PERF_STAT_EVSEL_ID__TRANSACTION_START,
16 PERF_STAT_EVSEL_ID__ELISION_START,
17 PERF_STAT_EVSEL_ID__CYCLES_IN_TX_CP,
Jiri Olsae2f56da2015-06-04 15:50:55 +020018 PERF_STAT_EVSEL_ID__MAX,
19};
20
21struct perf_stat {
22 struct stats res_stats[3];
23 enum perf_stat_evsel_id id;
24};
25
Xiao Guangrong0007ece2012-09-17 16:31:14 +080026void update_stats(struct stats *stats, u64 val);
27double avg_stats(struct stats *stats);
28double stddev_stats(struct stats *stats);
29double rel_stddev_stats(double stddev, double avg);
30
David Ahernffe4f3c2013-08-02 14:05:40 -060031static inline void init_stats(struct stats *stats)
32{
33 stats->n = 0.0;
34 stats->mean = 0.0;
35 stats->M2 = 0.0;
36 stats->min = (u64) -1;
37 stats->max = 0;
38}
Jiri Olsae2f56da2015-06-04 15:50:55 +020039
40struct perf_evsel;
41bool __perf_evsel_stat__is(struct perf_evsel *evsel,
42 enum perf_stat_evsel_id id);
43
44#define perf_stat_evsel__is(evsel, id) \
45 __perf_evsel_stat__is(evsel, PERF_STAT_EVSEL_ID__ ## id)
46
47void perf_stat_evsel_id_init(struct perf_evsel *evsel);
48
Xiao Guangrong0007ece2012-09-17 16:31:14 +080049#endif