diff options
| author | Enrico Granata <egranata@apple.com> | 2013-03-14 19:00:42 +0000 |
|---|---|---|
| committer | Enrico Granata <egranata@apple.com> | 2013-03-14 19:00:42 +0000 |
| commit | 86910577ccfc9da4b5d21a2d1844a4781413c80a (patch) | |
| tree | 8301d26ab3bd2460c8ed65485e3ab1488a5d210b /lldb/tools/lldb-perf/lib | |
| parent | 928f65a8aaca0383d24cf036b757bc120eaebcf4 (diff) | |
| download | bcm5719-llvm-86910577ccfc9da4b5d21a2d1844a4781413c80a.tar.gz bcm5719-llvm-86910577ccfc9da4b5d21a2d1844a4781413c80a.zip | |
<rdar://problem/13228487>
A test case for the performance of some LLDB formatters
Changes and improvements to the testing infrastructure itself
llvm-svn: 177100
Diffstat (limited to 'lldb/tools/lldb-perf/lib')
| -rw-r--r-- | lldb/tools/lldb-perf/lib/Measurement.h | 53 | ||||
| -rw-r--r-- | lldb/tools/lldb-perf/lib/Metric.cpp | 16 | ||||
| -rw-r--r-- | lldb/tools/lldb-perf/lib/Metric.h | 6 | ||||
| -rw-r--r-- | lldb/tools/lldb-perf/lib/TestCase.cpp | 10 | ||||
| -rw-r--r-- | lldb/tools/lldb-perf/lib/TestCase.h | 10 | ||||
| -rw-r--r-- | lldb/tools/lldb-perf/lib/Xcode.cpp | 2 |
6 files changed, 80 insertions, 17 deletions
diff --git a/lldb/tools/lldb-perf/lib/Measurement.h b/lldb/tools/lldb-perf/lib/Measurement.h index 0697b0fe30f..4623bdf8f6f 100644 --- a/lldb/tools/lldb-perf/lib/Measurement.h +++ b/lldb/tools/lldb-perf/lib/Measurement.h @@ -10,6 +10,7 @@ #define __PerfTestDriver__Measurement__ #include "Gauge.h" +#include "Timer.h" #include "Metric.h" namespace lldb { namespace perf @@ -18,10 +19,19 @@ template <typename GaugeType, typename Action> class Measurement : public WriteToPList { public: - Measurement (Action act, const char* name = NULL) : + Measurement () {} + + Measurement (Action act, const char* name = NULL, const char* descr = NULL) : m_action (act), - m_metric (Metric<typename GaugeType::SizeType>(name)) + m_metric (Metric<typename GaugeType::SizeType>(name,descr)) {} + + template <typename GaugeType_Rhs, typename Action_Rhs> + Measurement (const Measurement<GaugeType_Rhs, Action_Rhs>& rhs) : + m_action(rhs.action()), + m_metric(rhs.metric()) + { + } template <typename... Args> void @@ -31,22 +41,55 @@ public: m_metric.append (gauge.gauge(m_action,args...)); } - Metric<typename GaugeType::SizeType> - metric () + virtual const Metric<typename GaugeType::SizeType>& + metric () const { return m_metric; } + virtual const Action& + action () const + { + return m_action; + } + virtual void Write (CFCMutableArray& parent) { m_metric.Write(parent); } -private: +protected: Action m_action; Metric<typename GaugeType::SizeType> m_metric; }; + +template <typename Action> +class TimeMeasurement : public Measurement<TimeGauge,Action> +{ +public: + TimeMeasurement () : Measurement<TimeGauge,Action> () + {} + + TimeMeasurement (Action act, const char* name = NULL, const char* descr = NULL) : Measurement<TimeGauge,Action> (act, name, descr) + {} + + template <typename Action_Rhs> + TimeMeasurement (const TimeMeasurement<Action_Rhs>& rhs) : Measurement<TimeGauge,Action>(rhs) + {} + + template <typename GaugeType_Rhs, typename Action_Rhs> + TimeMeasurement (const Measurement<GaugeType_Rhs, Action_Rhs>& rhs) : Measurement<GaugeType_Rhs,Action_Rhs>(rhs) + {} + + template <typename... Args> + void + operator () (Args... args) + { + Measurement<TimeGauge,Action>::operator()(args...); + } +}; + } } #endif /* defined(__PerfTestDriver__Measurement__) */ diff --git a/lldb/tools/lldb-perf/lib/Metric.cpp b/lldb/tools/lldb-perf/lib/Metric.cpp index 885413fc65a..3791dd35409 100644 --- a/lldb/tools/lldb-perf/lib/Metric.cpp +++ b/lldb/tools/lldb-perf/lib/Metric.cpp @@ -19,8 +19,9 @@ Metric<T>::Metric () : Metric ("") {} template <class T> -Metric<T>::Metric (const char* n) : +Metric<T>::Metric (const char* n, const char* d) : m_name(n ? n : ""), +m_description(d ? d : ""), m_dataset () {} @@ -63,10 +64,18 @@ Metric<T>::name () } template <class T> +const char* +Metric<T>::description () +{ + return m_description.c_str(); +} + +template <class T> void Metric<T>::WriteImpl (CFCMutableArray& parent, identity<double>) { CFCMutableDictionary dict; - dict.AddValueCString(CFCString("name").get(),m_name.c_str(), true); + dict.AddValueCString(CFCString("name").get(),name(), true); + dict.AddValueCString(CFCString("description").get(),description(), true); dict.AddValueDouble(CFCString("value").get(),this->average(), true); parent.AppendValue(dict.get(), true); } @@ -75,7 +84,8 @@ template <class T> void Metric<T>::WriteImpl (CFCMutableArray& parent, identity<mach_vm_size_t>) { CFCMutableDictionary dict; - dict.AddValueCString(CFCString("name").get(),m_name.c_str(), true); + dict.AddValueCString(CFCString("name").get(),name(), true); + dict.AddValueCString(CFCString("description").get(),description(), true); dict.AddValueUInt64(CFCString("value").get(),this->average(), true); parent.AppendValue(dict.get(), true); } diff --git a/lldb/tools/lldb-perf/lib/Metric.h b/lldb/tools/lldb-perf/lib/Metric.h index 33ed6c27443..874169522ad 100644 --- a/lldb/tools/lldb-perf/lib/Metric.h +++ b/lldb/tools/lldb-perf/lib/Metric.h @@ -31,7 +31,7 @@ template <class ValueType> class Metric : public WriteToPList { public: Metric (); - Metric (const char*); + Metric (const char*, const char* = NULL); void append (ValueType v); @@ -48,6 +48,9 @@ public: const char* name (); + const char* + description (); + virtual void Write (CFCMutableArray& parent) { @@ -64,6 +67,7 @@ private: void WriteImpl (CFCMutableArray& parent, identity<mach_vm_size_t>); std::string m_name; + std::string m_description; std::vector<ValueType> m_dataset; }; } } diff --git a/lldb/tools/lldb-perf/lib/TestCase.cpp b/lldb/tools/lldb-perf/lib/TestCase.cpp index 2067969f81a..beb335f6613 100644 --- a/lldb/tools/lldb-perf/lib/TestCase.cpp +++ b/lldb/tools/lldb-perf/lib/TestCase.cpp @@ -18,17 +18,17 @@ m_process(), m_thread(), m_listener(), m_verbose(false) -{} - -void -TestCase::Setup (int argc, const char** argv) { - SBDebugger::Initialize(); + SBDebugger::Initialize(); SBHostOS::ThreadCreated ("<lldb-tester.app.main>"); m_debugger = SBDebugger::Create(false); m_listener = m_debugger.GetListener(); } +void +TestCase::Setup (int argc, const char** argv) +{} + bool TestCase::Launch (const char** args, const char* cwd) { diff --git a/lldb/tools/lldb-perf/lib/TestCase.h b/lldb/tools/lldb-perf/lib/TestCase.h index f2d67de6662..c4d449a330a 100644 --- a/lldb/tools/lldb-perf/lib/TestCase.h +++ b/lldb/tools/lldb-perf/lib/TestCase.h @@ -59,9 +59,15 @@ public: Results () = 0; template <typename G,typename A> - Measurement<G,A> CreateMeasurement (A a, const char* name = NULL) + Measurement<G,A> CreateMeasurement (A a, const char* name = NULL, const char* description = NULL) { - return Measurement<G,A> (a,name); + return Measurement<G,A> (a,name, description); + } + + template <typename A> + TimeMeasurement<A> CreateTimeMeasurement (A a, const char* name = NULL, const char* description = NULL) + { + return TimeMeasurement<A> (a,name, description); } static void diff --git a/lldb/tools/lldb-perf/lib/Xcode.cpp b/lldb/tools/lldb-perf/lib/Xcode.cpp index fd2d2c4406c..730844d520f 100644 --- a/lldb/tools/lldb-perf/lib/Xcode.cpp +++ b/lldb/tools/lldb-perf/lib/Xcode.cpp @@ -32,7 +32,7 @@ Xcode::FetchVariable (SBValue value, uint32_t expand, bool verbose) auto count = value.GetNumChildren(); for (int i = 0; i < count; i++) { - SBValue child(value.GetChildAtIndex(i)); + SBValue child(value.GetChildAtIndex(i,value.IsDynamic() ? lldb::eDynamicCanRunTarget : lldb::eNoDynamicValues, true)); FetchVariable (child,expand-1,verbose); } } |

