45#include "debug/Stats.hh"
54 : mergedParent(nullptr)
58 }
else if (parent && !
name) {
75 [[maybe_unused]]
const Named *named = \
76 dynamic_cast<const Named *>(
this);
77 DPRINTF(Stats,
"%s: regStats in group %s\n",
78 named ? named->
name() :
"?",
95 g.second->resetStats();
105 g.second->preDumpStats();
111 stats.push_back(info);
120 panic_if(block ==
this,
"Stat group can't be added to itself");
122 "Stats of the same group share the same name `%s`.\n",
name);
130 auto pos =
name.find(
".");
131 if (pos == std::string::npos) {
133 for (
auto &info :
stats) {
134 if (info->name ==
name) {
140 const std::string gname =
name.substr(0, pos);
142 if (
g.first == gname) {
143 return g.second->resolveStat(
name.substr(pos + 1));
150 auto info =
g->resolveStat(
name);
162 panic_if(!block,
"No stat block provided");
164 "Stat group already merged into another group");
165 panic_if(block ==
this,
"Stat group can't merge with itself");
172 for (
auto &
s : block->
stats)
180const std::map<std::string, Group *> &
Interface for things with names.
virtual std::string name() const
std::vector< Group * > mergedStatGroups
std::map< std::string, Group * > statGroups
const Info * resolveStat(std::string name) const
Resolve a stat by its name within this group.
std::vector< Info * > stats
Group * mergedParent
Parent pointer if merged into parent.
void mergeStatGroup(Group *block)
Merge the contents (stats & children) of a block to this block.
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
const std::map< std::string, Group * > & getStatGroups() const
Get all child groups associated with this object.
const std::vector< Info * > & getStats() const
Get all stats associated with this object.
virtual void regStats()
Callback to set stat parameters.
void addStatGroup(const char *name, Group *block)
Add a stat block as a child of this block.
virtual void preDumpStats()
Callback before stats are dumped.
void addStat(statistics::Info *info)
Register a stat with this group.
virtual void resetStats()
Callback to reset stats.
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
const std::string & name()