diff options
author | Nilay Vaish <nilay@cs.wisc.edu> | 2014-01-10 16:19:40 -0600 |
---|---|---|
committer | Nilay Vaish <nilay@cs.wisc.edu> | 2014-01-10 16:19:40 -0600 |
commit | cfe912a5127b51273d7e3e78c15095ac832f20bd (patch) | |
tree | 1585ad1befbbcb9bd50e1dc02c96cf9b1cccf209 /src/base/stats | |
parent | 0387281e2a83fe34ddb23cc48a9f86fd60729d25 (diff) | |
download | gem5-cfe912a5127b51273d7e3e78c15095ac832f20bd.tar.xz |
stats: add function for adding two histograms
This patch adds a function to the HistStor class for adding two histograms.
This functionality is required for Ruby. It also adds support for printing
histograms in a single line.
Diffstat (limited to 'src/base/stats')
-rw-r--r-- | src/base/stats/text.cc | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc index 25b8cb2e7..7d25b94e5 100644 --- a/src/base/stats/text.cc +++ b/src/base/stats/text.cc @@ -210,7 +210,7 @@ ScalarPrint::update(Result val, Result total) void ScalarPrint::operator()(ostream &stream, bool oneLine) const { - if ((flags.isSet(nozero) && value == 0.0) || + if ((flags.isSet(nozero) && (!oneLine) && value == 0.0) || (flags.isSet(nonan) && std::isnan(value))) return; @@ -312,7 +312,6 @@ VectorPrint::operator()(std::ostream &stream) const if (!desc.empty()) ccprintf(stream, " # %s", desc); } - stream << endl; } } @@ -325,10 +324,6 @@ VectorPrint::operator()(std::ostream &stream) const print.value = total; print(stream); } - - if (flags.isSet(oneline) && ((!flags.isSet(nozero)) || (total != 0))) { - stream << endl; - } } struct DistPrint @@ -380,6 +375,7 @@ DistPrint::init(const Text *text, const Info &info) void DistPrint::operator()(ostream &stream) const { + if (flags.isSet(nozero) && data.samples == 0) return; string base = name + separatorString; ScalarPrint print; @@ -390,6 +386,20 @@ DistPrint::operator()(ostream &stream) const print.pdf = NAN; print.cdf = NAN; + if (flags.isSet(oneline)) { + print.name = base + "bucket_size"; + print.value = data.bucket_size; + print(stream); + + print.name = base + "min_bucket"; + print.value = data.min; + print(stream); + + print.name = base + "max_bucket"; + print.value = data.max; + print(stream); + } + print.name = base + "samples"; print.value = data.samples; print(stream); @@ -436,6 +446,10 @@ DistPrint::operator()(ostream &stream) const print(stream); } + if (flags.isSet(oneline)) { + ccprintf(stream, "%-40s", name); + } + for (off_type i = 0; i < size; ++i) { stringstream namestr; namestr << base; @@ -448,7 +462,15 @@ DistPrint::operator()(ostream &stream) const print.name = namestr.str(); print.update(data.cvec[i], total); - print(stream); + print(stream, flags.isSet(oneline)); + } + + if (flags.isSet(oneline)) { + if (descriptions) { + if (!desc.empty()) + ccprintf(stream, " # %s", desc); + } + stream << endl; } if (data.type == Dist && data.overflow != NAN) { |