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 <vector>
14 #include <string>
15 #include <mach/task_info.h>
16 
17 namespace lldb_perf {
18 
19 class MemoryStats;
20 
21 template <class ValueType>
22 class Metric
23 {
24 public:
25     enum class StandardDeviationMode
26     {
27         eSample,
28         ePopulation
29     };
30 
31     Metric ();
32     Metric (const char*, const char* = NULL);
33 
34     void
35     Append (ValueType v);
36 
37     ValueType
38     GetAverage () const;
39 
40     size_t
41     GetCount () const;
42 
43     ValueType
44     GetSum () const;
45 
46     ValueType
47     GetStandardDeviation (StandardDeviationMode mode = StandardDeviationMode::ePopulation) const;
48 
49     const char*
GetName()50     GetName () const
51     {
52         if (m_name.empty())
53             return NULL;
54         return m_name.c_str();
55     }
56 
57     const char*
GetDescription()58     GetDescription () const
59     {
60         if (m_description.empty())
61             return NULL;
62         return m_description.c_str();
63     }
64 
65 private:
66     std::string m_name;
67     std::string m_description;
68     std::vector<ValueType> m_dataset;
69 };
70 }
71 
72 #endif /* defined(__PerfTestDriver__Metric__) */
73