mirror of
https://github.com/intel/llvm.git
synced 2026-01-20 10:18:14 +08:00
Modify code to adhere to LLDB coding conventions.
llvm-svn: 177623
This commit is contained in:
@@ -119,25 +119,25 @@ public:
|
||||
auto sstr3 = frame_zero.FindVariable("sstr3", lldb::eDynamicCanRunTarget);
|
||||
auto sstr4 = frame_zero.FindVariable("sstr4", lldb::eDynamicCanRunTarget);
|
||||
|
||||
m_dump_std_string_measurement.start();
|
||||
m_dump_std_string_measurement.Start();
|
||||
Xcode::FetchVariable(sstr0,0,false);
|
||||
m_dump_std_string_measurement.stop();
|
||||
m_dump_std_string_measurement.Stop();
|
||||
|
||||
m_dump_std_string_measurement.start();
|
||||
m_dump_std_string_measurement.Start();
|
||||
Xcode::FetchVariable(sstr1,0,false);
|
||||
m_dump_std_string_measurement.stop();
|
||||
m_dump_std_string_measurement.Stop();
|
||||
|
||||
m_dump_std_string_measurement.start();
|
||||
m_dump_std_string_measurement.Start();
|
||||
Xcode::FetchVariable(sstr2,0,false);
|
||||
m_dump_std_string_measurement.stop();
|
||||
m_dump_std_string_measurement.Stop();
|
||||
|
||||
m_dump_std_string_measurement.start();
|
||||
m_dump_std_string_measurement.Start();
|
||||
Xcode::FetchVariable(sstr3,0,false);
|
||||
m_dump_std_string_measurement.stop();
|
||||
m_dump_std_string_measurement.Stop();
|
||||
|
||||
m_dump_std_string_measurement.start();
|
||||
m_dump_std_string_measurement.Start();
|
||||
Xcode::FetchVariable(sstr4,0,false);
|
||||
m_dump_std_string_measurement.stop();
|
||||
m_dump_std_string_measurement.Stop();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
|
||||
#include <functional>
|
||||
|
||||
namespace lldb_perf
|
||||
{
|
||||
namespace lldb_perf {
|
||||
|
||||
template <class TASizeType>
|
||||
class Gauge
|
||||
{
|
||||
@@ -27,21 +27,21 @@ public:
|
||||
{}
|
||||
|
||||
virtual void
|
||||
start () = 0;
|
||||
Start () = 0;
|
||||
|
||||
virtual SizeType
|
||||
stop () = 0;
|
||||
Stop () = 0;
|
||||
|
||||
virtual SizeType
|
||||
value () = 0;
|
||||
GetValue () = 0;
|
||||
|
||||
template <typename F, typename... Args>
|
||||
SizeType
|
||||
gauge (F f,Args... args)
|
||||
Measure (F f,Args... args)
|
||||
{
|
||||
start();
|
||||
Start();
|
||||
f(args...);
|
||||
return stop();
|
||||
return Stop();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -20,19 +20,25 @@ template <typename GaugeType, typename Action>
|
||||
class Measurement : public WriteToPList
|
||||
{
|
||||
public:
|
||||
Measurement () {}
|
||||
Measurement () :
|
||||
m_gauge (),
|
||||
m_action (),
|
||||
m_metric ()
|
||||
{
|
||||
}
|
||||
|
||||
Measurement (Action act, const char* name = NULL, const char* descr = NULL) :
|
||||
m_gauge (),
|
||||
m_action (act),
|
||||
m_metric (Metric<typename GaugeType::SizeType>(name,descr))
|
||||
{}
|
||||
Measurement (Action act, const char* name = NULL, const char* desc = NULL) :
|
||||
m_gauge (),
|
||||
m_action (act),
|
||||
m_metric (Metric<typename GaugeType::SizeType>(name, desc))
|
||||
{
|
||||
}
|
||||
|
||||
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())
|
||||
m_gauge(rhs.GetGauge()),
|
||||
m_action(rhs.GetAction()),
|
||||
m_metric(rhs.GetMetric())
|
||||
{
|
||||
}
|
||||
|
||||
@@ -40,41 +46,41 @@ public:
|
||||
void
|
||||
operator () (Args... args)
|
||||
{
|
||||
m_metric.append (m_gauge.gauge(m_action,args...));
|
||||
m_metric.Append (m_gauge.Measure(m_action, args...));
|
||||
}
|
||||
|
||||
virtual const Action&
|
||||
GetAction () const
|
||||
{
|
||||
return m_action;
|
||||
}
|
||||
|
||||
virtual const GaugeType&
|
||||
GetGauge () const
|
||||
{
|
||||
return m_gauge;
|
||||
}
|
||||
|
||||
virtual const Metric<typename GaugeType::SizeType>&
|
||||
metric () const
|
||||
GetMetric () const
|
||||
{
|
||||
return m_metric;
|
||||
}
|
||||
|
||||
void
|
||||
start ()
|
||||
Start ()
|
||||
{
|
||||
m_gauge.start();
|
||||
m_gauge.Start();
|
||||
}
|
||||
|
||||
typename GaugeType::SizeType
|
||||
stop ()
|
||||
Stop ()
|
||||
{
|
||||
auto value = m_gauge.stop();
|
||||
m_metric.append(value);
|
||||
auto value = m_gauge.Stop();
|
||||
m_metric.Append(value);
|
||||
return value;
|
||||
}
|
||||
|
||||
virtual const GaugeType&
|
||||
gauge () const
|
||||
{
|
||||
return m_gauge;
|
||||
}
|
||||
|
||||
virtual const Action&
|
||||
action () const
|
||||
{
|
||||
return m_action;
|
||||
}
|
||||
|
||||
|
||||
virtual void
|
||||
Write (CFCMutableArray& parent)
|
||||
{
|
||||
@@ -91,19 +97,29 @@ template <typename Action>
|
||||
class TimeMeasurement : public Measurement<TimeGauge,Action>
|
||||
{
|
||||
public:
|
||||
TimeMeasurement () : Measurement<TimeGauge,Action> ()
|
||||
{}
|
||||
TimeMeasurement () :
|
||||
Measurement<TimeGauge,Action> ()
|
||||
{
|
||||
}
|
||||
|
||||
TimeMeasurement (Action act, const char* name = NULL, const char* descr = NULL) : Measurement<TimeGauge,Action> (act, name, descr)
|
||||
{}
|
||||
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)
|
||||
{}
|
||||
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)
|
||||
{}
|
||||
TimeMeasurement (const Measurement<GaugeType_Rhs, Action_Rhs>& rhs) :
|
||||
Measurement<GaugeType_Rhs,Action_Rhs>(rhs)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void
|
||||
@@ -118,18 +134,22 @@ class MemoryMeasurement : public Measurement<MemoryGauge,Action>
|
||||
{
|
||||
public:
|
||||
MemoryMeasurement () : Measurement<MemoryGauge,Action> ()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
MemoryMeasurement (Action act, const char* name = NULL, const char* descr = NULL) : Measurement<MemoryGauge,Action> (act, name, descr)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Action_Rhs>
|
||||
MemoryMeasurement (const MemoryMeasurement<Action_Rhs>& rhs) : Measurement<MemoryGauge,Action>(rhs)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
template <typename GaugeType_Rhs, typename Action_Rhs>
|
||||
MemoryMeasurement (const Measurement<GaugeType_Rhs, Action_Rhs>& rhs) : Measurement<GaugeType_Rhs,Action_Rhs>(rhs)
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
template <typename... Args>
|
||||
void
|
||||
|
||||
@@ -14,20 +14,27 @@
|
||||
|
||||
using namespace lldb_perf;
|
||||
|
||||
MemoryStats::MemoryStats () : MemoryStats(0,0,0) {}
|
||||
MemoryStats::MemoryStats (mach_vm_size_t vs,mach_vm_size_t rs, mach_vm_size_t mrs) :
|
||||
m_virtual_size(vs),
|
||||
m_resident_size(rs),
|
||||
m_max_resident_size(mrs)
|
||||
{}
|
||||
MemoryStats::MemoryStats (mach_vm_size_t virtual_size,
|
||||
mach_vm_size_t resident_size,
|
||||
mach_vm_size_t max_resident_size) :
|
||||
m_virtual_size (virtual_size),
|
||||
m_resident_size (resident_size),
|
||||
m_max_resident_size (max_resident_size)
|
||||
{
|
||||
}
|
||||
|
||||
MemoryStats::MemoryStats (const MemoryStats& rhs) :
|
||||
m_virtual_size (rhs.m_virtual_size),
|
||||
m_resident_size (rhs.m_resident_size),
|
||||
m_max_resident_size (rhs.m_max_resident_size)
|
||||
{
|
||||
}
|
||||
|
||||
MemoryStats::MemoryStats (const MemoryStats& rhs) : MemoryStats(rhs.m_virtual_size,rhs.m_resident_size,rhs.m_max_resident_size)
|
||||
{}
|
||||
|
||||
MemoryStats&
|
||||
MemoryStats::operator = (const MemoryStats& rhs)
|
||||
{
|
||||
if (&rhs != this)
|
||||
if (this != &rhs)
|
||||
{
|
||||
m_virtual_size = rhs.m_virtual_size;
|
||||
m_resident_size = rhs.m_resident_size;
|
||||
@@ -54,16 +61,16 @@ MemoryStats::operator - (const MemoryStats& rhs)
|
||||
}
|
||||
|
||||
MemoryStats&
|
||||
MemoryStats::operator / (size_t rhs)
|
||||
MemoryStats::operator / (size_t n)
|
||||
{
|
||||
m_virtual_size /= rhs;
|
||||
m_resident_size /= rhs;
|
||||
m_max_resident_size /= rhs;
|
||||
m_virtual_size /= n;
|
||||
m_resident_size /= n;
|
||||
m_max_resident_size /= n;
|
||||
return *this;
|
||||
}
|
||||
|
||||
MemoryGauge::SizeType
|
||||
MemoryGauge::now ()
|
||||
MemoryGauge::Now ()
|
||||
{
|
||||
task_t task = mach_task_self();
|
||||
mach_task_basic_info_data_t taskBasicInfo;
|
||||
@@ -76,30 +83,30 @@ MemoryGauge::now ()
|
||||
}
|
||||
|
||||
MemoryGauge::MemoryGauge () :
|
||||
m_start(),
|
||||
m_state(MemoryGauge::State::eMSNeverUsed)
|
||||
m_start(),
|
||||
m_state(MemoryGauge::State::eNeverUsed)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
MemoryGauge::start ()
|
||||
MemoryGauge::Start ()
|
||||
{
|
||||
m_state = MemoryGauge::State::eMSCounting;
|
||||
m_start = now();
|
||||
m_state = MemoryGauge::State::eCounting;
|
||||
m_start = Now();
|
||||
}
|
||||
|
||||
MemoryGauge::SizeType
|
||||
MemoryGauge::stop ()
|
||||
MemoryGauge::Stop ()
|
||||
{
|
||||
auto stop = now();
|
||||
assert(m_state == MemoryGauge::State::eMSCounting && "cannot stop a non-started gauge");
|
||||
m_state = MemoryGauge::State::eMSStopped;
|
||||
auto stop = Now();
|
||||
assert(m_state == MemoryGauge::State::eCounting && "cannot stop a non-started gauge");
|
||||
m_state = MemoryGauge::State::eStopped;
|
||||
return (m_value = stop-m_start);
|
||||
}
|
||||
|
||||
MemoryGauge::SizeType
|
||||
MemoryGauge::value ()
|
||||
MemoryGauge::GetValue ()
|
||||
{
|
||||
assert(m_state == MemoryGauge::State::eMSStopped && "gauge must be used before you can evaluate it");
|
||||
assert(m_state == MemoryGauge::State::eStopped && "gauge must be used before you can evaluate it");
|
||||
return m_value;
|
||||
}
|
||||
|
||||
@@ -18,8 +18,9 @@ namespace lldb_perf
|
||||
class MemoryStats
|
||||
{
|
||||
public:
|
||||
MemoryStats ();
|
||||
MemoryStats (mach_vm_size_t,mach_vm_size_t = 0, mach_vm_size_t = 0);
|
||||
MemoryStats (mach_vm_size_t virtual_size = 0,
|
||||
mach_vm_size_t resident_size = 0,
|
||||
mach_vm_size_t max_resident_size = 0);
|
||||
MemoryStats (const MemoryStats& rhs);
|
||||
|
||||
MemoryStats&
|
||||
@@ -78,36 +79,38 @@ private:
|
||||
|
||||
class MemoryGauge : public Gauge<MemoryStats>
|
||||
{
|
||||
private:
|
||||
enum class State
|
||||
{
|
||||
eMSNeverUsed,
|
||||
eMSCounting,
|
||||
eMSStopped
|
||||
};
|
||||
|
||||
SizeType
|
||||
now ();
|
||||
|
||||
SizeType m_start;
|
||||
State m_state;
|
||||
SizeType m_value;
|
||||
|
||||
public:
|
||||
MemoryGauge ();
|
||||
|
||||
virtual
|
||||
~MemoryGauge ()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
start ();
|
||||
Start ();
|
||||
|
||||
SizeType
|
||||
stop ();
|
||||
Stop ();
|
||||
|
||||
SizeType
|
||||
value ();
|
||||
GetValue ();
|
||||
|
||||
private:
|
||||
enum class State
|
||||
{
|
||||
eNeverUsed,
|
||||
eCounting,
|
||||
eStopped
|
||||
};
|
||||
|
||||
SizeType
|
||||
Now ();
|
||||
|
||||
SizeType m_start;
|
||||
State m_state;
|
||||
SizeType m_value;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -28,21 +28,21 @@ m_dataset ()
|
||||
|
||||
template <class T>
|
||||
void
|
||||
Metric<T>::append (T v)
|
||||
Metric<T>::Append (T v)
|
||||
{
|
||||
m_dataset.push_back(v);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
size_t
|
||||
Metric<T>::count ()
|
||||
Metric<T>::GetCount () const
|
||||
{
|
||||
return m_dataset.size();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T
|
||||
Metric<T>::sum ()
|
||||
Metric<T>::GetSum () const
|
||||
{
|
||||
T sum = 0;
|
||||
for (auto v : m_dataset)
|
||||
@@ -52,32 +52,18 @@ Metric<T>::sum ()
|
||||
|
||||
template <class T>
|
||||
T
|
||||
Metric<T>::average ()
|
||||
Metric<T>::GetAverage () const
|
||||
{
|
||||
return sum()/count();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
const char*
|
||||
Metric<T>::name ()
|
||||
{
|
||||
return m_name.c_str();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
const char*
|
||||
Metric<T>::description ()
|
||||
{
|
||||
return m_description.c_str();
|
||||
return GetSum()/GetCount();
|
||||
}
|
||||
|
||||
template <>
|
||||
void Metric<double>::WriteImpl (CFCMutableArray& parent, identity<double>)
|
||||
{
|
||||
CFCMutableDictionary dict;
|
||||
dict.AddValueCString(CFCString("name").get(),name(), true);
|
||||
dict.AddValueCString(CFCString("description").get(),description(), true);
|
||||
dict.AddValueDouble(CFCString("value").get(),this->average(), true);
|
||||
dict.AddValueCString(CFCString("name").get(), GetName(), true);
|
||||
dict.AddValueCString(CFCString("description").get(),GetDescription(), true);
|
||||
dict.AddValueDouble(CFCString("value").get(),this->GetAverage(), true);
|
||||
parent.AppendValue(dict.get(), true);
|
||||
}
|
||||
|
||||
@@ -85,17 +71,17 @@ template <>
|
||||
void Metric<MemoryStats>::WriteImpl (CFCMutableArray& parent, identity<MemoryStats>)
|
||||
{
|
||||
CFCMutableDictionary dict;
|
||||
dict.AddValueCString(CFCString("name").get(),name(), true);
|
||||
dict.AddValueCString(CFCString("description").get(),description(), true);
|
||||
dict.AddValueCString(CFCString("name").get(), GetName(), true);
|
||||
dict.AddValueCString(CFCString("description").get(), GetDescription(), true);
|
||||
CFCMutableDictionary value;
|
||||
|
||||
auto avg = this->average();
|
||||
auto avg = this->GetAverage();
|
||||
|
||||
value.AddValueUInt64(CFCString("virtual").get(), avg.GetVirtualSize(), true);
|
||||
value.AddValueUInt64(CFCString("resident").get(), avg.GetResidentSize(), true);
|
||||
value.AddValueUInt64(CFCString("max_resident").get(), avg.GetMaxResidentSize(), true);
|
||||
|
||||
dict.AddValue(CFCString("value").get(),value.get(), true);
|
||||
dict.AddValue(CFCString("value").get(), value.get(), true);
|
||||
|
||||
parent.AppendValue(dict.get(), true);
|
||||
}
|
||||
|
||||
@@ -15,9 +15,10 @@
|
||||
|
||||
#include "CFCMutableArray.h"
|
||||
|
||||
namespace lldb_perf
|
||||
{
|
||||
namespace lldb_perf {
|
||||
|
||||
class MemoryStats;
|
||||
|
||||
class WriteToPList
|
||||
{
|
||||
public:
|
||||
@@ -29,28 +30,35 @@ public:
|
||||
};
|
||||
|
||||
template <class ValueType>
|
||||
class Metric : public WriteToPList {
|
||||
class Metric : public WriteToPList
|
||||
{
|
||||
public:
|
||||
Metric ();
|
||||
Metric (const char*, const char* = NULL);
|
||||
|
||||
void
|
||||
append (ValueType v);
|
||||
Append (ValueType v);
|
||||
|
||||
ValueType
|
||||
GetAverage () const;
|
||||
|
||||
size_t
|
||||
count ();
|
||||
GetCount () const;
|
||||
|
||||
ValueType
|
||||
sum ();
|
||||
|
||||
ValueType
|
||||
average ();
|
||||
GetSum () const;
|
||||
|
||||
const char*
|
||||
name ();
|
||||
|
||||
GetName ()
|
||||
{
|
||||
return m_name.c_str();
|
||||
}
|
||||
|
||||
const char*
|
||||
description ();
|
||||
GetDescription ()
|
||||
{
|
||||
return m_description.c_str();
|
||||
}
|
||||
|
||||
virtual void
|
||||
Write (CFCMutableArray& parent)
|
||||
|
||||
@@ -67,7 +67,8 @@ public:
|
||||
|
||||
virtual
|
||||
~TestCase ()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
virtual bool
|
||||
Setup (int argc, const char** argv);
|
||||
|
||||
@@ -11,37 +11,37 @@
|
||||
|
||||
using namespace lldb_perf;
|
||||
|
||||
TimeGauge::HPTime
|
||||
TimeGauge::now ()
|
||||
TimeGauge::TimeType
|
||||
TimeGauge::Now ()
|
||||
{
|
||||
return high_resolution_clock::now();
|
||||
}
|
||||
|
||||
TimeGauge::TimeGauge () :
|
||||
m_start(),
|
||||
m_state(TimeGauge::State::eTSNeverUsed)
|
||||
m_state(TimeGauge::State::eNeverUsed)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
TimeGauge::start ()
|
||||
TimeGauge::Start ()
|
||||
{
|
||||
m_state = TimeGauge::State::eTSCounting;
|
||||
m_start = now();
|
||||
m_state = TimeGauge::State::eCounting;
|
||||
m_start = Now();
|
||||
}
|
||||
|
||||
double
|
||||
TimeGauge::stop ()
|
||||
TimeGauge::Stop ()
|
||||
{
|
||||
auto stop = now();
|
||||
assert(m_state == TimeGauge::State::eTSCounting && "cannot stop a non-started clock");
|
||||
m_state = TimeGauge::State::eTSStopped;
|
||||
auto stop = Now();
|
||||
assert(m_state == TimeGauge::State::eCounting && "cannot stop a non-started clock");
|
||||
m_state = TimeGauge::State::eStopped;
|
||||
return (m_value = duration_cast<duration<double>>(stop-m_start).count());
|
||||
}
|
||||
|
||||
double
|
||||
TimeGauge::value ()
|
||||
TimeGauge::GetValue ()
|
||||
{
|
||||
assert(m_state == TimeGauge::State::eTSStopped && "clock must be used before you can evaluate it");
|
||||
assert(m_state == TimeGauge::State::eStopped && "clock must be used before you can evaluate it");
|
||||
return m_value;
|
||||
}
|
||||
|
||||
@@ -22,34 +22,35 @@ class TimeGauge : public Gauge<double>
|
||||
private:
|
||||
enum class State
|
||||
{
|
||||
eTSNeverUsed,
|
||||
eTSCounting,
|
||||
eTSStopped
|
||||
eNeverUsed,
|
||||
eCounting,
|
||||
eStopped
|
||||
};
|
||||
|
||||
typedef high_resolution_clock::time_point HPTime;
|
||||
HPTime m_start;
|
||||
typedef high_resolution_clock::time_point TimeType;
|
||||
TimeType m_start;
|
||||
double m_value;
|
||||
State m_state;
|
||||
|
||||
HPTime
|
||||
now ();
|
||||
TimeType
|
||||
Now ();
|
||||
|
||||
public:
|
||||
TimeGauge ();
|
||||
|
||||
virtual
|
||||
~TimeGauge ()
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
start ();
|
||||
Start ();
|
||||
|
||||
double
|
||||
stop ();
|
||||
Stop ();
|
||||
|
||||
double
|
||||
value ();
|
||||
GetValue ();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user