16 #include <boost/algorithm/string.hpp>
19 #include <fmt/format.h>
23 #include <string_view>
39 {
"counter",
"{0:nEntries|10d}"},
40 {
"histogram",
"{0:nEntries|10d}"},
41 {
"counter:AveragingCounter",
"{0:nEntries|10d} |{0:sum|11.7g} |{0:mean|#11.5g}"},
42 {
"counter:SigmaCounter",
"{0:nEntries|10d} |{0:sum|11.7g} |{0:mean|#11.5g} |{0:standard_deviation|#11.5g}"},
43 {
"counter:StatCounter",
"{0:nEntries|10d} |{0:sum|11.7g} |{0:mean|#11.5g} |{0:standard_deviation|#11.5g} "
44 "|{0:min|#12.5g} |{0:max|#12.5g}"},
45 {
"counter:BinomialCounter",
46 "{0:nEntries|10d} |{0:nTrueEntries|11d} |({0:efficiency|#9.7p} +- {0:efficiencyErr|-#8.7p})%"},
62 template <
typename ParseContext>
64 auto fmt_begin =
ctx.begin();
66 if ( fmt_begin == fmt_end ) {
71 auto fmt_colon =
std::find( fmt_begin, fmt_end,
'|' );
72 currentName =
std::string( fmt_begin, fmt_colon - fmt_begin );
73 currentFormat =
std::string( fmt_colon + 1, fmt_end - fmt_colon - 1 );
77 template <
typename FormatContext>
79 if ( currentFormat.size() == 0 ) {
83 std::string_view type_key{
type};
85 auto entry =
registry.find( type_key );
87 auto sep = type_key.rfind(
':' );
88 while ( sep != type_key.npos && entry ==
registry.end() ) {
90 type_key.remove_suffix( type_key.size() - sep );
92 sep = type_key.rfind(
':' );
101 return fmt::format_to(
ctx.out(), entry->second, j );
104 auto actualFormat =
fmt::format(
"{{:{}", currentFormat ) +
"}";
105 switch ( currentFormat.back() ) {
107 return fmt::format_to(
ctx.out(), actualFormat, j.at( currentName ).template get<unsigned int>() );
109 return fmt::format_to(
ctx.out(), actualFormat, j.at( currentName ).template get<double>() );
111 actualFormat[actualFormat.size() - 2] =
'g';
112 return fmt::format_to(
ctx.out(), actualFormat, j.at( currentName ).template get<double>() * 100 );
114 return fmt::format_to(
ctx.out(),
"Unknown counter format : {}", currentFormat );
126 template <
typename stream>
131 if (
type ==
"statentity" ) {
132 using boost::algorithm::icontains;
133 bool isBinomial = icontains(
id,
"eff" ) || icontains(
id,
"acc" ) || icontains(
id,
"filt" ) ||
134 icontains(
id,
"fltr" ) || icontains(
id,
"pass" );
136 nj[
"type"] = isBinomial ?
"counter:BinomialCounter" :
"counter:StatCounter";
137 return printCounter(
log,
id, nj );
141 ( std::string_view{
type}.substr( 0, 23 ) ==
"counter:BinomialCounter" ?
'*' :
' ' ),
167 if ( std::string_view( ent.
type ).substr( 0, 8 ) ==
"counter:" || ent.
type ==
"statentity" ||
168 ent.
type ==
"histogram" ) {
194 for (
auto& entity :
m_monitoringEntities ) { sortedEntities[entity.component][entity.name] = entity.toJSON(); }
196 for (
auto& [algoName, entityMap] : sortedEntities ) {
198 unsigned int nbCounters =
200 return a + ( j.second.at(
"empty" ).
template get<bool>() ? 0 : 1 );
202 if ( 0 == nbCounters )
continue;
204 log <<
MSG::INFO <<
"Number of counters : " << nbCounters <<
"\n"
205 <<
" | Counter | # | "
206 <<
" sum | mean/eff^* | rms/err^* | min | max |";
209 if ( !p.second.at(
"empty" ).template get<bool>() ) {
211 printCounter( log, p.first, p.second );