Skip to content

Commit

Permalink
Fix reporting bug where ContextCounters have their per-context counts
Browse files Browse the repository at this point in the history
printed twice
  • Loading branch information
bdutro committed Apr 30, 2024
1 parent 102a119 commit 6a6696c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
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);
}
}

Expand Down

0 comments on commit 6a6696c

Please sign in to comment.