Skip to content

Commit

Permalink
WIP PerfGraphRegistry refs idaholab#15444
Browse files Browse the repository at this point in the history
  • Loading branch information
friedmud committed Jun 30, 2020
1 parent d67e18e commit a5def8f
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 14 deletions.
16 changes: 2 additions & 14 deletions framework/include/utils/PerfGraph.h
Expand Up @@ -228,18 +228,6 @@ class PerfGraph : protected ConsoleStreamInterface

typedef VariadicTable<std::string, unsigned long int, Real, Real, Real, long int> HeaviestTable;

/**
* 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;
};

/**
* Use to hold the time for each section
*
Expand Down Expand Up @@ -385,10 +373,10 @@ class PerfGraph : protected ConsoleStreamInterface
std::atomic<unsigned int> _execution_list_end;

/// Map of section names to IDs
std::map<std::string, PerfID> _section_name_to_id;
std::map<std::string, PerfID> & _section_name_to_id;

/// Map of IDs to section information
std::map<PerfID, SectionInfo> _id_to_section_info;
std::map<PerfID, SectionInfo> & _id_to_section_info;

/// The time for each section. This is updated on updateTiming()
/// Note that this is _total_ cumulative time across every place
Expand Down
78 changes: 78 additions & 0 deletions framework/include/utils/PerfGraphRegistry.h
@@ -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();
};


}
}
27 changes: 27 additions & 0 deletions framework/src/utils/PerfGraphRegistry.C
@@ -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)
{
}

}
}

0 comments on commit a5def8f

Please sign in to comment.