stat.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #ifndef __PERF_STATS_H
  2. #define __PERF_STATS_H
  3. #include <linux/types.h>
  4. #include <stdio.h>
  5. struct stats
  6. {
  7. double n, mean, M2;
  8. u64 max, min;
  9. };
  10. enum perf_stat_evsel_id {
  11. PERF_STAT_EVSEL_ID__NONE = 0,
  12. PERF_STAT_EVSEL_ID__CYCLES_IN_TX,
  13. PERF_STAT_EVSEL_ID__TRANSACTION_START,
  14. PERF_STAT_EVSEL_ID__ELISION_START,
  15. PERF_STAT_EVSEL_ID__CYCLES_IN_TX_CP,
  16. PERF_STAT_EVSEL_ID__MAX,
  17. };
  18. struct perf_stat {
  19. struct stats res_stats[3];
  20. enum perf_stat_evsel_id id;
  21. };
  22. enum aggr_mode {
  23. AGGR_NONE,
  24. AGGR_GLOBAL,
  25. AGGR_SOCKET,
  26. AGGR_CORE,
  27. };
  28. void update_stats(struct stats *stats, u64 val);
  29. double avg_stats(struct stats *stats);
  30. double stddev_stats(struct stats *stats);
  31. double rel_stddev_stats(double stddev, double avg);
  32. static inline void init_stats(struct stats *stats)
  33. {
  34. stats->n = 0.0;
  35. stats->mean = 0.0;
  36. stats->M2 = 0.0;
  37. stats->min = (u64) -1;
  38. stats->max = 0;
  39. }
  40. struct perf_evsel;
  41. bool __perf_evsel_stat__is(struct perf_evsel *evsel,
  42. enum perf_stat_evsel_id id);
  43. #define perf_stat_evsel__is(evsel, id) \
  44. __perf_evsel_stat__is(evsel, PERF_STAT_EVSEL_ID__ ## id)
  45. void perf_stat_evsel_id_init(struct perf_evsel *evsel);
  46. extern struct stats walltime_nsecs_stats;
  47. void perf_stat__reset_shadow_stats(void);
  48. void perf_stat__update_shadow_stats(struct perf_evsel *counter, u64 *count,
  49. int cpu);
  50. void perf_stat__print_shadow_stats(FILE *out, struct perf_evsel *evsel,
  51. double avg, int cpu, enum aggr_mode aggr);
  52. struct perf_counts *perf_counts__new(int ncpus);
  53. void perf_counts__delete(struct perf_counts *counts);
  54. void perf_evsel__reset_counts(struct perf_evsel *evsel, int ncpus);
  55. int perf_evsel__alloc_counts(struct perf_evsel *evsel, int ncpus);
  56. void perf_evsel__free_counts(struct perf_evsel *evsel);
  57. #endif