diff options
Diffstat (limited to 'src/base/stats/text.cc')
-rw-r--r-- | src/base/stats/text.cc | 53 |
1 files changed, 46 insertions, 7 deletions
diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc index 10e94a770..da68188bd 100644 --- a/src/base/stats/text.cc +++ b/src/base/stats/text.cc @@ -1,4 +1,16 @@ /* + * Copyright (c) 2019 Arm Limited + * All rights reserved. + * + * The license below extends only to copyright in the software and shall + * not be construed as granting a license to any other intellectual + * property including but not limited to intellectual property relating + * to a hardware implementation of the functionality of the software + * licensed hereunder. You may use the software subject to the license + * terms below provided that you ensure that this notice is replicated + * unmodified and in its entirety in all distributions of the software, + * modified or unmodified, in source code or in binary form. + * * Copyright (c) 2004-2005 The Regents of The University of Michigan * All rights reserved. * @@ -153,6 +165,32 @@ Text::end() stream->flush(); } +std::string +Text::statName(const std::string &name) const +{ + if (path.empty()) + return name; + else + return csprintf("%s.%s", path.top(), name); +} + +void +Text::beginGroup(const char *name) +{ + if (path.empty()) { + path.push(name); + } else { + path.push(csprintf("%s.%s", path.top(), name)); + } +} + +void +Text::endGroup() +{ + assert(!path.empty()); + path.pop(); +} + bool Text::noOutput(const Info &info) { @@ -368,7 +406,7 @@ DistPrint::DistPrint(const Text *text, const VectorDistInfo &info, int i) void DistPrint::init(const Text *text, const Info &info) { - name = info.name; + name = text->statName(info.name); separatorString = info.separatorString; desc = info.desc; flags = info.flags; @@ -511,7 +549,7 @@ Text::visit(const ScalarInfo &info) ScalarPrint print; print.value = info.result(); - print.name = info.name; + print.name = statName(info.name); print.desc = info.desc; print.flags = info.flags; print.descriptions = descriptions; @@ -531,7 +569,7 @@ Text::visit(const VectorInfo &info) size_type size = info.size(); VectorPrint print; - print.name = info.name; + print.name = statName(info.name); print.separatorString = info.separatorString; print.desc = info.desc; print.flags = info.flags; @@ -606,8 +644,9 @@ Text::visit(const Vector2dInfo &info) total += yvec[j]; } - print.name = info.name + "_" + - (havesub ? info.subnames[i] : std::to_string(i)); + print.name = statName( + info.name + "_" + + (havesub ? info.subnames[i] : std::to_string(i))); print.desc = info.desc; print.vec = yvec; print.total = total; @@ -619,7 +658,7 @@ Text::visit(const Vector2dInfo &info) total_subname.push_back("total"); if (info.flags.isSet(::Stats::total) && (info.x > 1)) { - print.name = info.name; + print.name = statName(info.name); print.subnames = total_subname; print.desc = info.desc; print.vec = VResult(1, info.total()); @@ -687,7 +726,7 @@ SparseHistPrint::SparseHistPrint(const Text *text, const SparseHistInfo &info) void SparseHistPrint::init(const Text *text, const Info &info) { - name = info.name; + name = text->statName(info.name); separatorString = info.separatorString; desc = info.desc; flags = info.flags; |