diff -r 782b7284de21 -r 1913012dc60b src/base/stats/info.hh --- a/src/base/stats/info.hh Tue May 21 11:57:14 2013 -0500 +++ b/src/base/stats/info.hh Thu May 23 11:29:59 2013 -0500 @@ -57,6 +57,8 @@ const FlagsType nozero = 0x0100; /** Don't print if this is NAN */ const FlagsType nonan = 0x0200; +/** Print all values on a single line. Useful only for histograms. */ +const FlagsType oneline = 0x0400; /** Mask of flags that can't be set directly */ const FlagsType __reserved = init | display; diff -r 782b7284de21 -r 1913012dc60b src/base/stats/text.cc --- a/src/base/stats/text.cc Tue May 21 11:57:14 2013 -0500 +++ b/src/base/stats/text.cc Thu May 23 11:29:59 2013 -0500 @@ -194,7 +194,7 @@ Result cdf; void update(Result val, Result total); - void operator()(ostream &stream) const; + void operator()(ostream &stream, bool oneLine = false) const; }; void @@ -208,7 +208,7 @@ } void -ScalarPrint::operator()(ostream &stream) const +ScalarPrint::operator()(ostream &stream, bool oneLine) const { if ((flags.isSet(nozero) && value == 0.0) || (flags.isSet(nonan) && std::isnan(value))) @@ -222,14 +222,19 @@ if (!std::isnan(cdf)) ccprintf(cdfstr, "%.2f%%", cdf * 100.0); - ccprintf(stream, "%-40s %12s %10s %10s", name, - ValueToString(value, precision), pdfstr.str(), cdfstr.str()); + if (oneLine) { + ccprintf(stream, " [%s %10s %10s]", + ValueToString(value, precision), pdfstr.str(), cdfstr.str()); + } else { + ccprintf(stream, "%-40s %12s %10s %10s", name, + ValueToString(value, precision), pdfstr.str(), cdfstr.str()); - if (descriptions) { - if (!desc.empty()) - ccprintf(stream, " # %s", desc); + if (descriptions) { + if (!desc.empty()) + ccprintf(stream, " # %s", desc); + } + stream << endl; } - stream << endl; } struct VectorPrint @@ -274,29 +279,44 @@ bool havesub = !subnames.empty(); if (_size == 1) { - print.value = vec[0]; + print.update(vec[0], _total); print(stream); return; } - for (off_type i = 0; i < _size; ++i) { - if (havesub && (i >= subnames.size() || subnames[i].empty())) - continue; + if ((!flags.isSet(nozero)) || (_total != 0)) { + if (flags.isSet(oneline)) { + ccprintf(stream, "%-40s", name); + } - print.name = base + (havesub ? subnames[i] : to_string(i)); - print.desc = subdescs.empty() ? desc : subdescs[i]; + for (off_type i = 0; i < _size; ++i) { + if (havesub && (i >= subnames.size() || subnames[i].empty())) + continue; - print.update(vec[i], _total); - print(stream); - } + print.name = base + (havesub ? subnames[i] : to_string(i)); + print.desc = subdescs.empty() ? desc : subdescs[i]; - if (flags.isSet(::Stats::total)) { - print.pdf = NAN; - print.cdf = NAN; - print.name = base + "total"; - print.desc = desc; - print.value = total; - print(stream); + print.update(vec[i], _total); + print(stream, flags.isSet(oneline)); + } + + if (flags.isSet(oneline)) { + if (descriptions) { + if (!desc.empty()) + ccprintf(stream, " # %s", desc); + } + + stream << endl; + } + + if (flags.isSet(::Stats::total)) { + print.pdf = NAN; + print.cdf = NAN; + print.name = base + "total"; + print.desc = desc; + print.value = total; + print(stream); + } } } @@ -384,6 +404,20 @@ if (data.type == Deviation) return; + if (flags.isSet(oneline)) { + print.name = base + "lower_bound"; + print.value = data.min; + print(stream); + + print.name = base + "upper_bound"; + print.value = data.max; + print(stream); + + print.name = base + "bucket_size"; + print.value = data.bucket_size; + print(stream); + } + size_t size = data.cvec.size(); Result total = 0.0; @@ -405,6 +439,10 @@ print(stream); } + if (flags.isSet(oneline)) { + stream << base + "data"; + } + for (off_type i = 0; i < size; ++i) { stringstream namestr; namestr << base; @@ -417,7 +455,11 @@ print.name = namestr.str(); print.update(data.cvec[i], total); - print(stream); + print(stream, flags.isSet(oneline)); + } + + if (flags.isSet(oneline)) { + stream << endl; } if (data.type == Dist && data.overflow != NAN) {