diff options
Diffstat (limited to 'lldb/tools/lldb-perf/lib/Metric.h')
-rw-r--r-- | lldb/tools/lldb-perf/lib/Metric.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/lldb/tools/lldb-perf/lib/Metric.h b/lldb/tools/lldb-perf/lib/Metric.h new file mode 100644 index 00000000000..33ed6c27443 --- /dev/null +++ b/lldb/tools/lldb-perf/lib/Metric.h @@ -0,0 +1,71 @@ +// +// Metric.h +// PerfTestDriver +// +// Created by Enrico Granata on 3/7/13. +// Copyright (c) 2013 Apple Inc. All rights reserved. +// + +#ifndef __PerfTestDriver__Metric__ +#define __PerfTestDriver__Metric__ + +#include <vector> +#include <string> +#include <mach/task_info.h> + +#include "CFCMutableArray.h" + +namespace lldb { namespace perf +{ +class WriteToPList +{ +public: + virtual void + Write (CFCMutableArray& parent) = 0; + + virtual + ~WriteToPList () {} +}; + +template <class ValueType> +class Metric : public WriteToPList { +public: + Metric (); + Metric (const char*); + + void + append (ValueType v); + + size_t + count (); + + ValueType + sum (); + + ValueType + average (); + + const char* + name (); + + virtual void + Write (CFCMutableArray& parent) + { + WriteImpl(parent, identity<ValueType>()); + } + +private: + + template<typename T> + struct identity { typedef T type; }; + + void WriteImpl (CFCMutableArray& parent, identity<double>); + + void WriteImpl (CFCMutableArray& parent, identity<mach_vm_size_t>); + + std::string m_name; + std::vector<ValueType> m_dataset; +}; +} } + +#endif /* defined(__PerfTestDriver__Metric__) */ |