Commit cd6c1299 authored by Sebastien Ponce's avatar Sebastien Ponce Committed by Charles Leggett
Browse files

Avoid printing empty counters

parent 37720f0c
......@@ -790,6 +790,8 @@ private:
Gaudi::Property<bool> m_errorsPrint{this, "ErrorsPrint", true, "print the statistics of errors/warnings/exceptions"};
Gaudi::Property<bool> m_propsPrint{this, "PropertiesPrint", false, "print the properties of the component"};
Gaudi::Property<bool> m_statPrint{this, "StatPrint", true, "print the table of counters"};
Gaudi::Property<bool> m_printEmptyCounters{this, "PrintEmptyCounters", false,
"force printing of empty counters, otherwise only printed in DEBUG mode"};
Gaudi::Property<bool> m_typePrint{this, "TypePrint", true, "add the actual C++ component type into the messages"};
Gaudi::Property<std::string> m_context{this, "Context", {}, "note: overridden by parent settings"};
......
......@@ -518,27 +518,33 @@ void GaudiCommon<PBASE>::Exception( const std::string& msg, const StatusCode sc
template <class PBASE>
long GaudiCommon<PBASE>::printStat( const MSG::Level level ) const
{
// print statistics
if ( m_counters.empty() ) {
// check how many counters think they should be printed or how many
// we anyway want to print
unsigned int nbPrintedCounters = 0;
if ( !m_printEmptyCounters && !this->msgLevel( MSG::DEBUG ) ) {
nbPrintedCounters = std::accumulate(
m_counters.begin(), m_counters.end(), nbPrintedCounters,
[]( unsigned int& sum, const auto& entry ) { return sum + entry.second.get().toBePrinted(); } );
} else {
nbPrintedCounters = m_counters.size();
}
// in case nothing should be printed, let's stop here
if ( nbPrintedCounters == 0 ) {
return 0;
}
MsgStream& msg = this->msgStream( level );
//
msg << "Number of counters : " << m_counters.size();
//
if ( !m_counters.empty() ) {
msg << "\n" << m_header.value();
}
//
msg << "Number of counters : " << nbPrintedCounters << "\n" << m_header.value();
for ( const auto& entry : m_counters ) {
std::ostringstream ost;
entry.second.get().print( ost, entry.first );
msg << "\n" << ost.str();
if ( m_printEmptyCounters || this->msgLevel( MSG::DEBUG ) || entry.second.get().toBePrinted() ) {
std::ostringstream ost;
entry.second.get().print( ost, entry.first );
msg << "\n" << ost.str();
}
}
//
msg << endmsg;
//
return m_counters.size();
return nbPrintedCounters;
}
// ============================================================================
......
......@@ -58,6 +58,7 @@ SimpleHistos DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
SimpleHistos DEBUG Property ['Name': Value] = 'RootInTES':
SimpleHistos DEBUG Property ['Name': Value] = 'Context':
SimpleHistos DEBUG Property ['Name': Value] = 'TypePrint':True
SimpleHistos DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
SimpleHistos DEBUG Property ['Name': Value] = 'StatPrint':True
SimpleHistos DEBUG Property ['Name': Value] = 'PropertiesPrint':False
SimpleHistos DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......@@ -122,6 +123,7 @@ Histos2 SUCCESS Property ['Name': Value] = 'StatTableHeader': | Co
Histos2 SUCCESS Property ['Name': Value] = 'RootInTES':
Histos2 SUCCESS Property ['Name': Value] = 'Context':
Histos2 SUCCESS Property ['Name': Value] = 'TypePrint':True
Histos2 SUCCESS Property ['Name': Value] = 'PrintEmptyCounters':False
Histos2 SUCCESS Property ['Name': Value] = 'StatPrint':True
Histos2 SUCCESS Property ['Name': Value] = 'PropertiesPrint':True
Histos2 SUCCESS Property ['Name': Value] = 'ErrorsPrint':True
......@@ -178,6 +180,7 @@ Aida2Root SUCCESS Property ['Name': Value] = 'StatTableHeader': | Co
Aida2Root SUCCESS Property ['Name': Value] = 'RootInTES':
Aida2Root SUCCESS Property ['Name': Value] = 'Context':
Aida2Root SUCCESS Property ['Name': Value] = 'TypePrint':True
Aida2Root SUCCESS Property ['Name': Value] = 'PrintEmptyCounters':False
Aida2Root SUCCESS Property ['Name': Value] = 'StatPrint':True
Aida2Root SUCCESS Property ['Name': Value] = 'PropertiesPrint':True
Aida2Root SUCCESS Property ['Name': Value] = 'ErrorsPrint':True
......
......@@ -74,6 +74,7 @@ ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'RootInTES':
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'Context':
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'TypePrint':True
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatPrint':True
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'PropertiesPrint':False
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......@@ -104,6 +105,7 @@ ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'RootInTES':
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'Context':
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'TypePrint':True
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatPrint':True
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'PropertiesPrint':False
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......
......@@ -60,6 +60,7 @@ MyAlg DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
MyAlg DEBUG Property ['Name': Value] = 'RootInTES':
MyAlg DEBUG Property ['Name': Value] = 'Context':
MyAlg DEBUG Property ['Name': Value] = 'TypePrint':True
MyAlg DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
MyAlg DEBUG Property ['Name': Value] = 'StatPrint':True
MyAlg DEBUG Property ['Name': Value] = 'PropertiesPrint':False
MyAlg DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......@@ -123,6 +124,7 @@ MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'RootInTES':
MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'Context':
MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'TypePrint':True
MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'StatPrint':True
MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'PropertiesPrint':False
MyAlg.MyGaudiTool DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......@@ -214,6 +216,7 @@ ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'RootInTES':
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'Context':
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'TypePrint':True
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatPrint':True
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'PropertiesPrint':False
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......@@ -245,6 +248,7 @@ ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'RootInTES':
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'Context':
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'TypePrint':True
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatPrint':True
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'PropertiesPrint':False
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......
......@@ -103,6 +103,7 @@ ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'RootInTES':
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'Context':
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'TypePrint':True
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'StatPrint':True
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'PropertiesPrint':False
ToolSvc.ToolA DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......@@ -134,6 +135,7 @@ ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'RootInTES':
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'Context':
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'TypePrint':True
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'StatPrint':True
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'PropertiesPrint':False
ToolSvc.ToolB DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......
......@@ -71,6 +71,7 @@ Fill SUCCESS Property ['Name': Value] = 'StatTableHeader': | Co
Fill SUCCESS Property ['Name': Value] = 'RootInTES':
Fill SUCCESS Property ['Name': Value] = 'Context':
Fill SUCCESS Property ['Name': Value] = 'TypePrint':False
Fill SUCCESS Property ['Name': Value] = 'PrintEmptyCounters':False
Fill SUCCESS Property ['Name': Value] = 'StatPrint':True
Fill SUCCESS Property ['Name': Value] = 'PropertiesPrint':True
Fill SUCCESS Property ['Name': Value] = 'ErrorsPrint':True
......
......@@ -38,6 +38,7 @@ Test1 DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
Test1 DEBUG Property ['Name': Value] = 'RootInTES':
Test1 DEBUG Property ['Name': Value] = 'Context':
Test1 DEBUG Property ['Name': Value] = 'TypePrint':True
Test1 DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
Test1 DEBUG Property ['Name': Value] = 'StatPrint':True
Test1 DEBUG Property ['Name': Value] = 'PropertiesPrint':False
Test1 DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......@@ -80,6 +81,7 @@ Test2 DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
Test2 DEBUG Property ['Name': Value] = 'RootInTES':microDST/
Test2 DEBUG Property ['Name': Value] = 'Context':
Test2 DEBUG Property ['Name': Value] = 'TypePrint':True
Test2 DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
Test2 DEBUG Property ['Name': Value] = 'StatPrint':True
Test2 DEBUG Property ['Name': Value] = 'PropertiesPrint':False
Test2 DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......
......@@ -56,6 +56,7 @@ SimpleHistos DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
SimpleHistos DEBUG Property ['Name': Value] = 'RootInTES':
SimpleHistos DEBUG Property ['Name': Value] = 'Context':
SimpleHistos DEBUG Property ['Name': Value] = 'TypePrint':True
SimpleHistos DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
SimpleHistos DEBUG Property ['Name': Value] = 'StatPrint':True
SimpleHistos DEBUG Property ['Name': Value] = 'PropertiesPrint':False
SimpleHistos DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......@@ -120,6 +121,7 @@ Histos2 SUCCESS Property ['Name': Value] = 'StatTableHeader': | Co
Histos2 SUCCESS Property ['Name': Value] = 'RootInTES':
Histos2 SUCCESS Property ['Name': Value] = 'Context':
Histos2 SUCCESS Property ['Name': Value] = 'TypePrint':True
Histos2 SUCCESS Property ['Name': Value] = 'PrintEmptyCounters':False
Histos2 SUCCESS Property ['Name': Value] = 'StatPrint':True
Histos2 SUCCESS Property ['Name': Value] = 'PropertiesPrint':True
Histos2 SUCCESS Property ['Name': Value] = 'ErrorsPrint':True
......
......@@ -77,6 +77,7 @@ Fill SUCCESS Property ['Name': Value] = 'StatTableHeader': | Co
Fill SUCCESS Property ['Name': Value] = 'RootInTES':
Fill SUCCESS Property ['Name': Value] = 'Context':
Fill SUCCESS Property ['Name': Value] = 'TypePrint':False
Fill SUCCESS Property ['Name': Value] = 'PrintEmptyCounters':False
Fill SUCCESS Property ['Name': Value] = 'StatPrint':True
Fill SUCCESS Property ['Name': Value] = 'PropertiesPrint':True
Fill SUCCESS Property ['Name': Value] = 'ErrorsPrint':True
......
......@@ -42,6 +42,7 @@ Test1 DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
Test1 DEBUG Property ['Name': Value] = 'RootInTES':
Test1 DEBUG Property ['Name': Value] = 'Context':
Test1 DEBUG Property ['Name': Value] = 'TypePrint':True
Test1 DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
Test1 DEBUG Property ['Name': Value] = 'StatPrint':True
Test1 DEBUG Property ['Name': Value] = 'PropertiesPrint':False
Test1 DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......@@ -84,6 +85,7 @@ Test2 DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
Test2 DEBUG Property ['Name': Value] = 'RootInTES':microDST/
Test2 DEBUG Property ['Name': Value] = 'Context':
Test2 DEBUG Property ['Name': Value] = 'TypePrint':True
Test2 DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
Test2 DEBUG Property ['Name': Value] = 'StatPrint':True
Test2 DEBUG Property ['Name': Value] = 'PropertiesPrint':False
Test2 DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......
......@@ -86,6 +86,7 @@ DataCreator DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
DataCreator DEBUG Property ['Name': Value] = 'RootInTES':
DataCreator DEBUG Property ['Name': Value] = 'Context':
DataCreator DEBUG Property ['Name': Value] = 'TypePrint':True
DataCreator DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
DataCreator DEBUG Property ['Name': Value] = 'StatPrint':True
DataCreator DEBUG Property ['Name': Value] = 'PropertiesPrint':False
DataCreator DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......@@ -135,6 +136,7 @@ OddEvents DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
OddEvents DEBUG Property ['Name': Value] = 'RootInTES':
OddEvents DEBUG Property ['Name': Value] = 'Context':
OddEvents DEBUG Property ['Name': Value] = 'TypePrint':True
OddEvents DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
OddEvents DEBUG Property ['Name': Value] = 'StatPrint':True
OddEvents DEBUG Property ['Name': Value] = 'PropertiesPrint':False
OddEvents DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......@@ -182,6 +184,7 @@ EvenEvents DEBUG Property ['Name': Value] = 'StatTableHeader': | Co
EvenEvents DEBUG Property ['Name': Value] = 'RootInTES':
EvenEvents DEBUG Property ['Name': Value] = 'Context':
EvenEvents DEBUG Property ['Name': Value] = 'TypePrint':True
EvenEvents DEBUG Property ['Name': Value] = 'PrintEmptyCounters':False
EvenEvents DEBUG Property ['Name': Value] = 'StatPrint':True
EvenEvents DEBUG Property ['Name': Value] = 'PropertiesPrint':False
EvenEvents DEBUG Property ['Name': Value] = 'ErrorsPrint':True
......
......@@ -640,6 +640,9 @@ namespace Gaudi
o << boost::format{" | %|-48.48s|%|50t|"} % ( "\"" + tag + "\"" );
return print( o, true );
}
/** hint whether we should print that counter or not.
Typically empty counters may not be printed */
virtual bool toBePrinted() const { return true; }
/// get a string representation
std::string toString() const
{
......@@ -689,6 +692,7 @@ namespace Gaudi
using BufferableCounter<Arithmetic, Atomicity, Counter>::print;
std::ostream& print( std::ostream& o, bool tableFormat = false ) const override
{
// Avoid printing empty counters in non DEBUG mode
std::string fmt( "#=%|-7lu|" );
if ( tableFormat ) {
fmt = "|%|10d| |";
......@@ -696,6 +700,11 @@ namespace Gaudi
o << boost::format{fmt} % this->nEntries();
return o;
}
virtual bool toBePrinted() const override
{
return this->nEntries() > 0;
;
}
};
/**
......@@ -717,6 +726,11 @@ namespace Gaudi
}
return o << boost::format{fmt} % this->nEntries() % this->sum() % this->mean();
}
virtual bool toBePrinted() const override
{
return this->nEntries() > 0;
;
}
};
template <typename Arithmetic = double, atomicity Atomicity = atomicity::full>
using SummingCounter = AveragingCounter<Arithmetic, Atomicity>;
......@@ -740,6 +754,11 @@ namespace Gaudi
}
return o << boost::format{fmt} % this->nEntries() % this->sum() % this->mean() % this->standard_deviation();
}
virtual bool toBePrinted() const override
{
return this->nEntries() > 0;
;
}
};
/**
......@@ -761,6 +780,7 @@ namespace Gaudi
return o << boost::format{fmt} % this->nEntries() % this->sum() % this->mean() % this->standard_deviation() %
this->min() % this->max();
}
virtual bool toBePrinted() const override { return this->nEntries() > 0; }
};
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment