Clean up function logging for non-DCF part of stats module
This commit is contained in:
@@ -35,18 +35,18 @@ const double ns3::NaN = zero / zero;
|
||||
DataCalculator::DataCalculator() :
|
||||
m_enabled (true)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
|
||||
DataCalculator::~DataCalculator()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
|
||||
void
|
||||
DataCalculator::DoDispose (void)
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
Simulator::Cancel (m_startEvent);
|
||||
Simulator::Cancel (m_stopEvent);
|
||||
@@ -59,6 +59,8 @@ DataCalculator::DoDispose (void)
|
||||
void
|
||||
DataCalculator::SetKey (const std::string key)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << key);
|
||||
|
||||
m_key = key;
|
||||
// end DataCalculator::SetKey
|
||||
}
|
||||
@@ -66,6 +68,8 @@ DataCalculator::SetKey (const std::string key)
|
||||
std::string
|
||||
DataCalculator::GetKey () const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
return m_key;
|
||||
// end DataCalculator::GetKey
|
||||
}
|
||||
@@ -74,6 +78,8 @@ DataCalculator::GetKey () const
|
||||
void
|
||||
DataCalculator::SetContext (const std::string context)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << context);
|
||||
|
||||
m_context = context;
|
||||
// end DataCalculator::SetContext
|
||||
}
|
||||
@@ -81,6 +87,8 @@ DataCalculator::SetContext (const std::string context)
|
||||
std::string
|
||||
DataCalculator::GetContext () const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
return m_context;
|
||||
// end DataCalculator::GetContext
|
||||
}
|
||||
@@ -88,6 +96,8 @@ DataCalculator::GetContext () const
|
||||
void
|
||||
DataCalculator::Enable ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
m_enabled = true;
|
||||
// end DataCalculator::Enable
|
||||
}
|
||||
@@ -95,6 +105,8 @@ DataCalculator::Enable ()
|
||||
void
|
||||
DataCalculator::Disable ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
m_enabled = false;
|
||||
// end DataCalculator::Disable
|
||||
}
|
||||
@@ -102,6 +114,8 @@ DataCalculator::Disable ()
|
||||
bool
|
||||
DataCalculator::GetEnabled () const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
return m_enabled;
|
||||
// end DataCalculator::GetEnabled
|
||||
}
|
||||
@@ -110,6 +124,7 @@ DataCalculator::GetEnabled () const
|
||||
void
|
||||
DataCalculator::Start (const Time& startTime)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << startTime);
|
||||
|
||||
m_startEvent = Simulator::Schedule (startTime,
|
||||
&DataCalculator::Enable, this);
|
||||
@@ -120,6 +135,8 @@ DataCalculator::Start (const Time& startTime)
|
||||
void
|
||||
DataCalculator::Stop (const Time& stopTime)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << stopTime);
|
||||
|
||||
m_stopEvent = Simulator::Schedule (stopTime,
|
||||
&DataCalculator::Disable, this);
|
||||
// end DataCalculator::Stop
|
||||
|
||||
@@ -31,17 +31,17 @@ NS_LOG_COMPONENT_DEFINE ("DataCollector");
|
||||
//--------------------------------------------------------------
|
||||
//----------------------------------------------
|
||||
DataCollector::DataCollector() {
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_LOG_FUNCTION (this);
|
||||
// end DataCollector::DataCollector
|
||||
}
|
||||
|
||||
DataCollector::~DataCollector() {
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_LOG_FUNCTION (this);
|
||||
// end DataCollector::~DataCollector
|
||||
}
|
||||
|
||||
void DataCollector::DoDispose () {
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
m_calcList.clear ();
|
||||
m_metadata.clear ();
|
||||
@@ -57,6 +57,7 @@ DataCollector::DescribeRun (std::string experiment,
|
||||
std::string runID,
|
||||
std::string description)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << experiment << strategy << input << runID << description);
|
||||
|
||||
m_experimentLabel = experiment;
|
||||
m_strategyLabel = strategy;
|
||||
@@ -70,6 +71,7 @@ DataCollector::DescribeRun (std::string experiment,
|
||||
void
|
||||
DataCollector::AddDataCalculator (Ptr<DataCalculator> datac)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << datac);
|
||||
|
||||
m_calcList.push_back (datac);
|
||||
|
||||
@@ -92,6 +94,8 @@ DataCollector::DataCalculatorEnd ()
|
||||
void
|
||||
DataCollector::AddMetadata (std::string key, std::string value)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << key << value);
|
||||
|
||||
std::pair<std::string, std::string> blob (key, value);
|
||||
m_metadata.push_back (blob);
|
||||
// end DataCollector::AddMetadata
|
||||
@@ -99,6 +103,8 @@ DataCollector::AddMetadata (std::string key, std::string value)
|
||||
void
|
||||
DataCollector::AddMetadata (std::string key, uint32_t value)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << key << value);
|
||||
|
||||
std::stringstream st;
|
||||
st << value;
|
||||
|
||||
@@ -109,6 +115,8 @@ DataCollector::AddMetadata (std::string key, uint32_t value)
|
||||
void
|
||||
DataCollector::AddMetadata (std::string key, double value)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << key << value);
|
||||
|
||||
std::stringstream st;
|
||||
st << value;
|
||||
|
||||
|
||||
@@ -31,16 +31,16 @@ NS_LOG_COMPONENT_DEFINE ("DataOutputInterface");
|
||||
//----------------------------------------------
|
||||
DataOutputInterface::DataOutputInterface()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
DataOutputInterface::~DataOutputInterface()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
void
|
||||
DataOutputInterface::DoDispose ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
Object::DoDispose ();
|
||||
// end DataOutputInterface::DoDispose
|
||||
@@ -49,11 +49,15 @@ DataOutputInterface::DoDispose ()
|
||||
void
|
||||
DataOutputInterface::SetFilePrefix (const std::string prefix)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << prefix);
|
||||
|
||||
m_filePrefix = prefix;
|
||||
}
|
||||
|
||||
std::string
|
||||
DataOutputInterface::GetFilePrefix () const
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
return m_filePrefix;
|
||||
}
|
||||
|
||||
@@ -37,18 +37,18 @@ NS_LOG_COMPONENT_DEFINE ("OmnetDataOutput");
|
||||
//----------------------------------------------
|
||||
OmnetDataOutput::OmnetDataOutput()
|
||||
{
|
||||
m_filePrefix = "data";
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
m_filePrefix = "data";
|
||||
}
|
||||
OmnetDataOutput::~OmnetDataOutput()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
void
|
||||
OmnetDataOutput::DoDispose ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
DataOutputInterface::DoDispose ();
|
||||
// end OmnetDataOutput::DoDispose
|
||||
@@ -85,6 +85,7 @@ inline bool isNumeric (const std::string& s) {
|
||||
void
|
||||
OmnetDataOutput::Output (DataCollector &dc)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << &dc);
|
||||
|
||||
std::ofstream scalarFile;
|
||||
std::string fn = m_filePrefix +"-"+dc.GetRunLabel ()+ ".sca";
|
||||
@@ -139,6 +140,7 @@ OmnetDataOutput::OmnetOutputCallback::OmnetOutputCallback
|
||||
(std::ostream *scalar) :
|
||||
m_scalar (scalar)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << scalar);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -146,6 +148,8 @@ OmnetDataOutput::OmnetOutputCallback::OutputStatistic (std::string context,
|
||||
std::string name,
|
||||
const StatisticalSummary *statSum)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << context << name << statSum);
|
||||
|
||||
if (context == "")
|
||||
context = ".";
|
||||
if (name == "")
|
||||
@@ -172,6 +176,8 @@ OmnetDataOutput::OmnetOutputCallback::OutputSingleton (std::string context,
|
||||
std::string name,
|
||||
int val)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << context << name << val);
|
||||
|
||||
if (context == "")
|
||||
context = ".";
|
||||
if (name == "")
|
||||
@@ -185,6 +191,8 @@ OmnetDataOutput::OmnetOutputCallback::OutputSingleton (std::string context,
|
||||
std::string name,
|
||||
uint32_t val)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << context << name << val);
|
||||
|
||||
if (context == "")
|
||||
context = ".";
|
||||
if (name == "")
|
||||
@@ -198,6 +206,8 @@ OmnetDataOutput::OmnetOutputCallback::OutputSingleton (std::string context,
|
||||
std::string name,
|
||||
double val)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << context << name << val);
|
||||
|
||||
if (context == "")
|
||||
context = ".";
|
||||
if (name == "")
|
||||
@@ -211,6 +221,8 @@ OmnetDataOutput::OmnetOutputCallback::OutputSingleton (std::string context,
|
||||
std::string name,
|
||||
std::string val)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << context << name << val);
|
||||
|
||||
if (context == "")
|
||||
context = ".";
|
||||
if (name == "")
|
||||
@@ -224,6 +236,8 @@ OmnetDataOutput::OmnetOutputCallback::OutputSingleton (std::string context,
|
||||
std::string name,
|
||||
Time val)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << context << name << val);
|
||||
|
||||
if (context == "")
|
||||
context = ".";
|
||||
if (name == "")
|
||||
|
||||
@@ -37,17 +37,18 @@ NS_LOG_COMPONENT_DEFINE ("SqliteDataOutput");
|
||||
//----------------------------------------------
|
||||
SqliteDataOutput::SqliteDataOutput()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
m_filePrefix = "data";
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
}
|
||||
SqliteDataOutput::~SqliteDataOutput()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
void
|
||||
SqliteDataOutput::DoDispose ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
DataOutputInterface::DoDispose ();
|
||||
// end SqliteDataOutput::DoDispose
|
||||
@@ -55,6 +56,8 @@ SqliteDataOutput::DoDispose ()
|
||||
|
||||
int
|
||||
SqliteDataOutput::Exec (std::string exe) {
|
||||
NS_LOG_FUNCTION (this << exe);
|
||||
|
||||
int res;
|
||||
char **result;
|
||||
int nrows, ncols;
|
||||
@@ -100,6 +103,8 @@ SqliteDataOutput::Exec (std::string exe) {
|
||||
void
|
||||
SqliteDataOutput::Output (DataCollector &dc)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << &dc);
|
||||
|
||||
std::string m_dbFile = m_filePrefix + ".db";
|
||||
|
||||
if (sqlite3_open (m_dbFile.c_str (), &m_db)) {
|
||||
@@ -149,6 +154,7 @@ SqliteDataOutput::SqliteOutputCallback::SqliteOutputCallback
|
||||
m_owner (owner),
|
||||
m_runLabel (run)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << owner << run);
|
||||
|
||||
m_owner->Exec ("create table if not exists Singletons ( run text, name text, variable text, value )");
|
||||
|
||||
@@ -160,6 +166,8 @@ SqliteDataOutput::SqliteOutputCallback::OutputStatistic (std::string key,
|
||||
std::string variable,
|
||||
const StatisticalSummary *statSum)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << key << variable << statSum);
|
||||
|
||||
OutputSingleton (key,variable+"-count", (double)statSum->getCount ());
|
||||
if (!isNaN (statSum->getSum ()))
|
||||
OutputSingleton (key,variable+"-total", statSum->getSum ());
|
||||
@@ -179,6 +187,7 @@ SqliteDataOutput::SqliteOutputCallback::OutputSingleton (std::string key,
|
||||
std::string variable,
|
||||
int val)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << key << variable << val);
|
||||
|
||||
std::stringstream sstr;
|
||||
sstr << "insert into Singletons (run,name,variable,value) values ('" <<
|
||||
@@ -195,6 +204,8 @@ SqliteDataOutput::SqliteOutputCallback::OutputSingleton (std::string key,
|
||||
std::string variable,
|
||||
uint32_t val)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << key << variable << val);
|
||||
|
||||
std::stringstream sstr;
|
||||
sstr << "insert into Singletons (run,name,variable,value) values ('" <<
|
||||
m_runLabel << "', '" <<
|
||||
@@ -209,6 +220,8 @@ SqliteDataOutput::SqliteOutputCallback::OutputSingleton (std::string key,
|
||||
std::string variable,
|
||||
double val)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << key << variable << val);
|
||||
|
||||
std::stringstream sstr;
|
||||
sstr << "insert into Singletons (run,name,variable,value) values ('" <<
|
||||
m_runLabel << "', '" <<
|
||||
@@ -223,6 +236,8 @@ SqliteDataOutput::SqliteOutputCallback::OutputSingleton (std::string key,
|
||||
std::string variable,
|
||||
std::string val)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << key << variable << val);
|
||||
|
||||
std::stringstream sstr;
|
||||
sstr << "insert into Singletons (run,name,variable,value) values ('" <<
|
||||
m_runLabel << "', '" <<
|
||||
@@ -237,6 +252,8 @@ SqliteDataOutput::SqliteOutputCallback::OutputSingleton (std::string key,
|
||||
std::string variable,
|
||||
Time val)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << key << variable << val);
|
||||
|
||||
std::stringstream sstr;
|
||||
sstr << "insert into Singletons (run,name,variable,value) values ('" <<
|
||||
m_runLabel << "', '" <<
|
||||
|
||||
@@ -32,14 +32,19 @@ NS_LOG_COMPONENT_DEFINE ("TimeDataCalculators");
|
||||
//----------------------------------------------
|
||||
TimeMinMaxAvgTotalCalculator::TimeMinMaxAvgTotalCalculator()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
m_count = 0;
|
||||
}
|
||||
TimeMinMaxAvgTotalCalculator::~TimeMinMaxAvgTotalCalculator()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
}
|
||||
void
|
||||
TimeMinMaxAvgTotalCalculator::DoDispose (void)
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
|
||||
DataCalculator::DoDispose ();
|
||||
// TimeMinMaxAvgTotalCalculator::DoDispose
|
||||
}
|
||||
@@ -47,6 +52,8 @@ TimeMinMaxAvgTotalCalculator::DoDispose (void)
|
||||
void
|
||||
TimeMinMaxAvgTotalCalculator::Update (const Time i)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << i);
|
||||
|
||||
if (m_enabled) {
|
||||
if (m_count) {
|
||||
m_total += i;
|
||||
@@ -70,6 +77,8 @@ TimeMinMaxAvgTotalCalculator::Update (const Time i)
|
||||
void
|
||||
TimeMinMaxAvgTotalCalculator::Output (DataOutputCallback &callback) const
|
||||
{
|
||||
NS_LOG_FUNCTION (this << &callback);
|
||||
|
||||
callback.OutputSingleton (m_context, m_key + "-count", m_count);
|
||||
if (m_count > 0) {
|
||||
callback.OutputSingleton (m_context, m_key + "-total", m_total);
|
||||
|
||||
Reference in New Issue
Block a user