geopm  3.1.1.dev214+gba4f9f6d
GEOPM - Global Extensible Open Power Manager
RuntimeStats.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 - 2024 Intel Corporation
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef RUNTIMESTATS_HPP_INCLUDE
7 #define RUNTIMESTATS_HPP_INCLUDE
8 
9 #include <vector>
10 #include <string>
11 #include <cstdint>
12 
13 namespace geopm
14 {
17  {
18  public:
19  RuntimeStats() = delete;
21  RuntimeStats(const std::vector<std::string> &metric_names);
23  virtual ~RuntimeStats() = default;
27  int num_metric(void) const;
34  std::string metric_name(int metric_idx) const;
41  uint64_t count(int metric_idx) const;
48  double first(int metric_idx) const;
55  double last(int metric_idx) const;
62  double min(int metric_idx) const;
69  double max(int metric_idx) const;
76  double mean(int metric_idx) const;
83  double std(int metric_idx) const;
85  void reset(void);
92  void update(const std::vector<double> &sample);
93  private:
94  void check_index(int metric_idx, const std::string &func, int line) const;
95  struct stats_s {
96  stats_s &operator=(const stats_s &other);
97  uint64_t count;
98  double first;
99  double last;
100  double min;
101  double max;
102  double m_1; // sum of all sampled values
103  double m_2; // sum of the square of all sampled values
104  };
105  const std::vector<std::string> m_metric_names;
106  std::vector<stats_s> m_metric_stats;
107  };
108 }
109 
110 #endif
Class that aggregates statistics without buffered data.
Definition: RuntimeStats.hpp:17
double last(int metric_idx) const
Last non-null value sampled.
Definition: RuntimeStats.cpp:57
void update(const std::vector< double > &sample)
Update statistics with new sample.
Definition: RuntimeStats.cpp:126
double max(int metric_idx) const
Maximum value sampled.
Definition: RuntimeStats.cpp:77
virtual ~RuntimeStats()=default
Default virtual destructor.
double std(int metric_idx) const
Estimate of standard deviation.
Definition: RuntimeStats.cpp:98
void reset(void)
Reset all aggregated statistics.
Definition: RuntimeStats.cpp:117
double mean(int metric_idx) const
Mean value sampled.
Definition: RuntimeStats.cpp:87
uint64_t count(int metric_idx) const
Number of non-null values sampled.
Definition: RuntimeStats.cpp:41
std::string metric_name(int metric_idx) const
Name of one metrics.
Definition: RuntimeStats.cpp:35
double first(int metric_idx) const
First non-null value sampled.
Definition: RuntimeStats.cpp:47
int num_metric(void) const
Number of metrics aggregated.
Definition: RuntimeStats.cpp:22
double min(int metric_idx) const
Minimum value sampled.
Definition: RuntimeStats.cpp:67
Definition: Agg.cpp:20