summaryrefslogtreecommitdiff
path: root/src/base/statistics.cc
diff options
context:
space:
mode:
authorNilay Vaish <nilay@cs.wisc.edu>2014-01-10 16:19:40 -0600
committerNilay Vaish <nilay@cs.wisc.edu>2014-01-10 16:19:40 -0600
commitcfe912a5127b51273d7e3e78c15095ac832f20bd (patch)
tree1585ad1befbbcb9bd50e1dc02c96cf9b1cccf209 /src/base/statistics.cc
parent0387281e2a83fe34ddb23cc48a9f86fd60729d25 (diff)
downloadgem5-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/statistics.cc')
-rw-r--r--src/base/statistics.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/base/statistics.cc b/src/base/statistics.cc
index 0b44a4ec7..2bd34d3db 100644
--- a/src/base/statistics.cc
+++ b/src/base/statistics.cc
@@ -352,6 +352,27 @@ HistStor::grow_up()
bucket_size *= 2;
}
+void
+HistStor::add(HistStor *hs)
+{
+ int b_size = hs->size();
+ assert(size() == b_size);
+ assert(min_bucket == hs->min_bucket);
+
+ sum += hs->sum;
+ logs += hs->logs;
+ squares += hs->squares;
+ samples += hs->samples;
+
+ while(bucket_size > hs->bucket_size)
+ hs->grow_up();
+ while(bucket_size < hs->bucket_size)
+ grow_up();
+
+ for (uint32_t i = 0; i < b_size; i++)
+ cvec[i] += hs->cvec[i];
+}
+
Formula::Formula()
{
}