# Node ID 75cfba1230c11bc8282852f75474096207c9047b # Parent 6fc8f1dda721ea430eea2f29fbfe594c37e7c4e5 diff --git a/src/base/statistics.hh b/src/base/statistics.hh --- a/src/base/statistics.hh +++ b/src/base/statistics.hh @@ -159,6 +159,8 @@ { public: Vector2dInfoProxy(Stat &stat) : InfoProxy(stat) {} + + Result total() const { return this->s.total(); } }; struct StorageParams @@ -1298,6 +1300,19 @@ #endif } + /** + * Return a total of all entries in this vector. + * @return The total of all vector entries. + */ + Result + total() const + { + Result total = 0.0; + for (off_type i = 0; i < size(); ++i) + total += data(i)->result(); + return total; + } + void prepare() { diff --git a/src/base/stats/info.hh b/src/base/stats/info.hh --- a/src/base/stats/info.hh +++ b/src/base/stats/info.hh @@ -229,6 +229,8 @@ mutable VCounter cvec; void enable(); + + virtual Result total() const = 0; }; class FormulaInfo : public VectorInfo diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc --- a/src/base/stats/text.cc +++ b/src/base/stats/text.cc @@ -588,7 +588,6 @@ } VResult tot_vec(info.y); - VResult super_total(1, 0.0); for (off_type i = 0; i < info.x; ++i) { if (havesub && (i >= info.subnames.size() || info.subnames[i].empty())) continue; @@ -601,7 +600,6 @@ yvec[j] = info.cvec[iy + j]; tot_vec[j] += yvec[j]; total += yvec[j]; - super_total[0] += yvec[j]; } print.name = info.name + "_" + @@ -620,7 +618,7 @@ print.name = info.name; print.subnames = total_subname; print.desc = info.desc; - print.vec = super_total; + print.vec = VResult(1, info.total()); print.flags = print.flags & ~total; print(*stream); }