[Lldb-commits] [lldb] r177597 - Making a manual mode of operation for measurements, where you can manually call start() and stop() instead of using the function-call syntax
Enrico Granata
egranata at apple.com
Wed Mar 20 16:01:28 PDT 2013
Author: enrico
Date: Wed Mar 20 18:01:28 2013
New Revision: 177597
URL: http://llvm.org/viewvc/llvm-project?rev=177597&view=rev
Log:
Making a manual mode of operation for measurements, where you can manually call start() and stop() instead of using the function-call syntax
This is especially useful to take measurements that span multiple test steps, or where you need to have different operations fall under the same measurement
An example of use is in the formatters perf test case
Modified:
lldb/trunk/tools/lldb-perf/darwin/formatters/formatters.cpp
lldb/trunk/tools/lldb-perf/lib/Measurement.h
Modified: lldb/trunk/tools/lldb-perf/darwin/formatters/formatters.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-perf/darwin/formatters/formatters.cpp?rev=177597&r1=177596&r2=177597&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-perf/darwin/formatters/formatters.cpp (original)
+++ lldb/trunk/tools/lldb-perf/darwin/formatters/formatters.cpp Wed Mar 20 18:01:28 2013
@@ -34,8 +34,9 @@ public:
m_dump_std_map_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
lldb_perf::Xcode::FetchVariable (value,1,false);
}, "std-map", "time to dump an std::map");
- m_dump_std_string_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
- lldb_perf::Xcode::FetchVariable (value,1,false);
+
+ // use this in manual mode
+ m_dump_std_string_measurement = CreateTimeMeasurement([] () -> void {
}, "std-string", "time to dump an std::string");
m_dump_nsstring_measurement = CreateTimeMeasurement([] (SBValue value) -> void {
@@ -112,11 +113,32 @@ public:
m_dump_std_list_measurement(frame_zero.FindVariable("list", lldb::eDynamicCanRunTarget));
m_dump_std_map_measurement(frame_zero.FindVariable("map", lldb::eDynamicCanRunTarget));
- m_dump_std_string_measurement(frame_zero.FindVariable("sstr0", lldb::eDynamicCanRunTarget));
- m_dump_std_string_measurement(frame_zero.FindVariable("sstr1", lldb::eDynamicCanRunTarget));
- m_dump_std_string_measurement(frame_zero.FindVariable("sstr2", lldb::eDynamicCanRunTarget));
- m_dump_std_string_measurement(frame_zero.FindVariable("sstr3", lldb::eDynamicCanRunTarget));
- m_dump_std_string_measurement(frame_zero.FindVariable("sstr4", lldb::eDynamicCanRunTarget));
+ auto sstr0 = frame_zero.FindVariable("sstr0", lldb::eDynamicCanRunTarget);
+ auto sstr1 = frame_zero.FindVariable("sstr1", lldb::eDynamicCanRunTarget);
+ auto sstr2 = frame_zero.FindVariable("sstr2", lldb::eDynamicCanRunTarget);
+ auto sstr3 = frame_zero.FindVariable("sstr3", lldb::eDynamicCanRunTarget);
+ auto sstr4 = frame_zero.FindVariable("sstr4", lldb::eDynamicCanRunTarget);
+
+ m_dump_std_string_measurement.start();
+ Xcode::FetchVariable(sstr0,0,false);
+ m_dump_std_string_measurement.stop();
+
+ m_dump_std_string_measurement.start();
+ Xcode::FetchVariable(sstr1,0,false);
+ m_dump_std_string_measurement.stop();
+
+ m_dump_std_string_measurement.start();
+ Xcode::FetchVariable(sstr2,0,false);
+ m_dump_std_string_measurement.stop();
+
+ m_dump_std_string_measurement.start();
+ Xcode::FetchVariable(sstr3,0,false);
+ m_dump_std_string_measurement.stop();
+
+ m_dump_std_string_measurement.start();
+ Xcode::FetchVariable(sstr4,0,false);
+ m_dump_std_string_measurement.stop();
+
}
virtual void
@@ -202,7 +224,7 @@ private:
TimeMeasurement<std::function<void(SBValue)>> m_dump_std_vector_measurement;
TimeMeasurement<std::function<void(SBValue)>> m_dump_std_list_measurement;
TimeMeasurement<std::function<void(SBValue)>> m_dump_std_map_measurement;
- TimeMeasurement<std::function<void(SBValue)>> m_dump_std_string_measurement;
+ TimeMeasurement<std::function<void()>> m_dump_std_string_measurement;
// Cocoa formatters
TimeMeasurement<std::function<void(SBValue)>> m_dump_nsstring_measurement;
Modified: lldb/trunk/tools/lldb-perf/lib/Measurement.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-perf/lib/Measurement.h?rev=177597&r1=177596&r2=177597&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-perf/lib/Measurement.h (original)
+++ lldb/trunk/tools/lldb-perf/lib/Measurement.h Wed Mar 20 18:01:28 2013
@@ -23,12 +23,14 @@ public:
Measurement () {}
Measurement (Action act, const char* name = NULL, const char* descr = NULL) :
+ m_gauge (),
m_action (act),
m_metric (Metric<typename GaugeType::SizeType>(name,descr))
{}
template <typename GaugeType_Rhs, typename Action_Rhs>
Measurement (const Measurement<GaugeType_Rhs, Action_Rhs>& rhs) :
+ m_gauge(rhs.gauge()),
m_action(rhs.action()),
m_metric(rhs.metric())
{
@@ -38,8 +40,7 @@ public:
void
operator () (Args... args)
{
- GaugeType gauge;
- m_metric.append (gauge.gauge(m_action,args...));
+ m_metric.append (m_gauge.gauge(m_action,args...));
}
virtual const Metric<typename GaugeType::SizeType>&
@@ -48,6 +49,26 @@ public:
return m_metric;
}
+ void
+ start ()
+ {
+ m_gauge.start();
+ }
+
+ typename GaugeType::SizeType
+ stop ()
+ {
+ auto value = m_gauge.stop();
+ m_metric.append(value);
+ return value;
+ }
+
+ virtual const GaugeType&
+ gauge () const
+ {
+ return m_gauge;
+ }
+
virtual const Action&
action () const
{
@@ -61,6 +82,7 @@ public:
}
protected:
+ GaugeType m_gauge;
Action m_action;
Metric<typename GaugeType::SizeType> m_metric;
};
More information about the lldb-commits
mailing list