X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=senf%2FUtils%2FStatistics.cc;fp=senf%2FUtils%2FStatistics.cc;h=730898d5c38c5b8f47ea078691a1f4cca6fe8799;hb=af697a0c8591b38f7ee7dbc3d1d0293f4ff72d37;hp=7506e078e41e1b511011d6e0c47994b8a96dab45;hpb=f37680c43dd9aab620388e9b966ed2328c56a15e;p=senf.git diff --git a/senf/Utils/Statistics.cc b/senf/Utils/Statistics.cc index 7506e07..730898d 100644 --- a/senf/Utils/Statistics.cc +++ b/senf/Utils/Statistics.cc @@ -30,6 +30,7 @@ #include #include #include +#include #include "StatisticsTargets.hh" //#include "Statistics.mpp" @@ -82,63 +83,25 @@ senf::StatisticsBase::output(unsigned n) return OutputProxy(this, &(i->second)); } -// -// generate an engineering style notation -// -std::string format_eng( float f) -{ - char buf[16]; - if (f > 0) { - int n = 0; - while( f >= 1000.0f) { - f /= 1000.0f; - n+=3; - } - - if( n >=3) - sprintf( buf, " %3.2fe%+03d", f, n); - else - sprintf( buf, " %3.2f", f); - } - else if (f < 0) { - int n = 0; - while( f <= -1000.0f) { - f *= 1000.0f; - n+=3; - } - if( n >=3) - sprintf( buf, " %3.2fe%+03d", f, n); - else - sprintf( buf, " %3.2f", f); - } - else{ - sprintf( buf, " 0.00"); - } - - return buf; -} - - prefix_ void senf::StatisticsBase::consoleList(unsigned level, std::ostream & os) const { - os << boost::format("%s%-5d%|15t| %12s %12s %12s %12s\n") + os << boost::format("%s%-5d%|15t| %12s %19.5g %12s\n") % std::string(2*level,' ') % rank() - % format_eng(min()) - % format_eng(avg()) - % format_eng(dev()) - % format_eng(max()); + % boost::io::group(std::setw(1),senf::format::eng(min())) + % boost::io::group(std::setw(1),senf::format::eng(avg(),dev())) + % boost::io::group(std::setw(1),senf::format::eng(max())); { OutputMap::const_iterator i (outputs_.begin()); OutputMap::const_iterator i_end (outputs_.end()); for (; i != i_end; ++i) - os << boost::format(" %3d %12s %12s %12s %12s\n") + os << boost::format(" %3d %12s %19.5g %12s\n") % i->second.n - % format_eng(i->second.min/i->second.n) - % format_eng(i->second.avg/i->second.n) - % format_eng(i->second.dev/i->second.n) - % format_eng(i->second.max/i->second.n); + % boost::io::group(std::setw(1),senf::format::eng(i->second.min/i->second.n)) + % boost::io::group(std::setw(1),senf::format::eng(i->second.avg/i->second.n, + i->second.dev/i->second.n)) + % boost::io::group(std::setw(1),senf::format::eng(i->second.max/i->second.n)); } { Children::const_iterator i (children_.begin()); @@ -245,7 +208,7 @@ prefix_ senf::Statistics::Statistics() prefix_ void senf::Statistics::consoleList(std::ostream & os) { - os << "RANK WIN MIN AVG DEV MAX\n"; + os << "RANK WIN MIN AVG MAX\n"; StatisticsBase::consoleList(0, os); }