From 86910577ccfc9da4b5d21a2d1844a4781413c80a Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Thu, 14 Mar 2013 19:00:42 +0000 Subject: A test case for the performance of some LLDB formatters Changes and improvements to the testing infrastructure itself llvm-svn: 177100 --- lldb/tools/lldb-perf/lib/Measurement.h | 53 ++++++++++++++++++++++++++++++---- lldb/tools/lldb-perf/lib/Metric.cpp | 16 ++++++++-- lldb/tools/lldb-perf/lib/Metric.h | 6 +++- lldb/tools/lldb-perf/lib/TestCase.cpp | 10 +++---- lldb/tools/lldb-perf/lib/TestCase.h | 10 +++++-- lldb/tools/lldb-perf/lib/Xcode.cpp | 2 +- 6 files changed, 80 insertions(+), 17 deletions(-) (limited to 'lldb/tools/lldb-perf/lib') 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 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(name)) + m_metric (Metric(name,descr)) {} + + template + Measurement (const Measurement& rhs) : + m_action(rhs.action()), + m_metric(rhs.metric()) + { + } template void @@ -31,22 +41,55 @@ public: m_metric.append (gauge.gauge(m_action,args...)); } - Metric - metric () + virtual const Metric& + 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 m_metric; }; + +template +class TimeMeasurement : public Measurement +{ +public: + TimeMeasurement () : Measurement () + {} + + TimeMeasurement (Action act, const char* name = NULL, const char* descr = NULL) : Measurement (act, name, descr) + {} + + template + TimeMeasurement (const TimeMeasurement& rhs) : Measurement(rhs) + {} + + template + TimeMeasurement (const Measurement& rhs) : Measurement(rhs) + {} + + template + void + operator () (Args... args) + { + Measurement::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::Metric () : Metric ("") {} template -Metric::Metric (const char* n) : +Metric::Metric (const char* n, const char* d) : m_name(n ? n : ""), +m_description(d ? d : ""), m_dataset () {} @@ -62,11 +63,19 @@ Metric::name () return m_name.c_str(); } +template +const char* +Metric::description () +{ + return m_description.c_str(); +} + template void Metric::WriteImpl (CFCMutableArray& parent, identity) { 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 void Metric::WriteImpl (CFCMutableArray& parent, identity) { 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 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); std::string m_name; + std::string m_description; std::vector 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 (""); 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 - Measurement CreateMeasurement (A a, const char* name = NULL) + Measurement CreateMeasurement (A a, const char* name = NULL, const char* description = NULL) { - return Measurement (a,name); + return Measurement (a,name, description); + } + + template + TimeMeasurement CreateTimeMeasurement (A a, const char* name = NULL, const char* description = NULL) + { + return TimeMeasurement (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); } } -- cgit v1.2.3