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 llvm-svn: 177597
This commit is contained in:
parent
4536d582fd
commit
e7ed0afee2
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue