]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/lldb-perf/lib/Metric.h
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / tools / lldb-perf / lib / Metric.h
1 //===-- Metric.h ------------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef __PerfTestDriver__Metric__
11 #define __PerfTestDriver__Metric__
12
13 #include <mach/task_info.h>
14 #include <string>
15 #include <vector>
16
17 namespace lldb_perf {
18
19 class MemoryStats;
20
21 template <class ValueType> class Metric {
22 public:
23   enum class StandardDeviationMode { eSample, ePopulation };
24
25   Metric();
26   Metric(const char *, const char * = NULL);
27
28   void Append(ValueType v);
29
30   ValueType GetAverage() const;
31
32   size_t GetCount() const;
33
34   ValueType GetSum() const;
35
36   ValueType GetStandardDeviation(
37       StandardDeviationMode mode = StandardDeviationMode::ePopulation) const;
38
39   const char *GetName() const {
40     if (m_name.empty())
41       return NULL;
42     return m_name.c_str();
43   }
44
45   const char *GetDescription() const {
46     if (m_description.empty())
47       return NULL;
48     return m_description.c_str();
49   }
50
51 private:
52   std::string m_name;
53   std::string m_description;
54   std::vector<ValueType> m_dataset;
55 };
56 }
57
58 #endif /* defined(__PerfTestDriver__Metric__) */