Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reporting bug where ContextCounters have their per-context counts printed twice #497

Merged
merged 4 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions sparta/sparta/report/Report.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ namespace sparta
* by another item immediately in this report (not the name of a
* subreport or item in a subreport)
*/
StatAdder add(const StatisticInstance& si, const std::string& name="");
StatAdder add(const StatisticInstance& si, const std::string& name="", const bool recurse=true);

/*!
* \brief Moves an existing statistic instance into this Report
Expand All @@ -414,7 +414,7 @@ namespace sparta
* by another item immediately in this report (not the name of a
* subreport or item in a subreport)
*/
StatAdder add(StatisticInstance&& si, const std::string& name="");
StatAdder add(StatisticInstance&& si, const std::string& name="", const bool recurse=true);

/*!
* \brief Add a StatisticDef to the report
Expand Down
14 changes: 9 additions & 5 deletions sparta/src/Report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ class ReportFileParserYAML
std::string filename_; //!< For recalling errors
}; // class ReportFileParserYAML

Report::StatAdder Report::add(const StatisticInstance& si, const std::string& name) {
Report::StatAdder Report::add(const StatisticInstance& si, const std::string& name, const bool recurse) {
if(name != "" && stat_names_.find(name) != stat_names_.end()){
throw SpartaException("There is already a statistic instance in this Report (")
<< getName() << ") named \"" << name << "\" pointing to "
Expand All @@ -1164,12 +1164,14 @@ Report::StatAdder Report::add(const StatisticInstance& si, const std::string& na

if(name != ""){ stat_names_.insert(name); }

addSubStatistics_(&si);
if(recurse) {
addSubStatistics_(&si);
}

return Report::StatAdder(*this);
}

Report::StatAdder Report::add(StatisticInstance&& si, const std::string& name) {
Report::StatAdder Report::add(StatisticInstance&& si, const std::string& name, const bool recurse) {
if(name != "" && stat_names_.find(name) != stat_names_.end()){
throw SpartaException("There is already a statistic instance in this Report (")
<< getName() << ") named \"" << name << "\" pointing to "
Expand All @@ -1183,7 +1185,9 @@ Report::StatAdder Report::add(StatisticInstance&& si, const std::string& name) {

if(name != ""){ stat_names_.insert(name); }

addSubStatistics_(&si);
if(recurse) {
addSubStatistics_(&si);
}

return Report::StatAdder(*this);
}
Expand Down Expand Up @@ -1416,7 +1420,7 @@ void Report::recursAddSubtree_(const TreeNode* n,
//for(auto& s : stats_){
// std::cerr << " Stat " << s.second->stringize() << " " << s.second->getLocation() << std::endl;
//}
add(n, child_stat_prefix + n->getName());
add(n, child_stat_prefix + n->getName(), false);
bdutro marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Loading