forked from idaholab/moose
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP PerfGraphRegistry refs idaholab#15444
- Loading branch information
Showing
3 changed files
with
107 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
//* This file is part of the MOOSE framework | ||
//* https://www.mooseframework.org | ||
//* | ||
//* All rights reserved, see COPYRIGHT for full restrictions | ||
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT | ||
//* | ||
//* Licensed under LGPL 2.1, please see LICENSE for details | ||
//* https://www.gnu.org/licenses/lgpl-2.1.html | ||
|
||
#pragma once | ||
|
||
#include "MooseTypes.h" | ||
|
||
|
||
namespace moose | ||
{ | ||
namespace internal | ||
{ | ||
|
||
// Forward Declarations | ||
class PerfGraphRegistry; | ||
|
||
PerfGraphRegistry & getPerfGraphRegistry(); | ||
|
||
/** | ||
* The place where all timed sections will be stored | ||
*/ | ||
class PerfGraphRegistry | ||
{ | ||
public: | ||
/** | ||
* Used to hold metadata about the registered sections | ||
*/ | ||
struct SectionInfo | ||
{ | ||
PerfID _id; | ||
std::string _name; | ||
unsigned int _level; | ||
std::string _live_message; | ||
bool _print_dots; | ||
}; | ||
|
||
/** | ||
* Call to register a named section for timing. | ||
* | ||
* @param section_name The name of the code section to be timed | ||
* @param level The importance of the timer - lower is more important (0 will always come out) | ||
* @return The ID of the section - use when starting timing | ||
*/ | ||
PerfID registerTimedSection(const std::string & section_name, const unsigned int level); | ||
|
||
/** | ||
* Call to register a named section for timing. | ||
* | ||
* @param section_name The name of the code section to be timed | ||
* @param level The importance of the timer - lower is more important (0 will always come out) | ||
* @param live_message The message to be printed to the screen during execution | ||
* @param print_dots Whether or not progress dots should be printed for this section | ||
* @return The ID of the section - use when starting timing | ||
*/ | ||
PerfID registerSection(const std::string & section_name, const unsigned int level, const std::string & live_message, const bool print_dots = true); | ||
|
||
protected: | ||
PerfGraphRegistry(); | ||
~PerfGraphRegistry(); | ||
|
||
/// Map of section names to IDs | ||
std::map<std::string, PerfID> _section_name_to_id; | ||
|
||
/// Map of IDs to section information | ||
std::map<PerfID, SectionInfo> _id_to_section_info; | ||
|
||
friend PerfGraphRegistry & getPerfGraphRegistry(); | ||
}; | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include "PerfGraphRegistry.h" | ||
|
||
namespace moose | ||
{ | ||
namespace internal | ||
{ | ||
|
||
PerfGraphRegistry & | ||
getPerfGraphRegistry() | ||
{ | ||
static PerfGraphRegistry perf_graph_registry_singleton; | ||
|
||
return perf_graph_registry_singleton; | ||
} | ||
|
||
PerfID | ||
PerfGraphRegistry::registerTimedSection(const std::string & section_name, const unsigned int level) | ||
{ | ||
} | ||
|
||
PerfID | ||
PerfGraphRegistry::registerSection(const std::string & section_name, const unsigned int level, const std::string & live_message, const bool print_dots = true) | ||
{ | ||
} | ||
|
||
} | ||
} |