https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PerfGraphRegistry.C
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#include "PerfGraphRegistry.h"
11
12#include "DataIO.h"
13
14namespace moose
15{
16namespace internal
17{
18
19PerfGraphRegistry &
21{
22 // In C++11 this is even thread safe! (Lookup "Static Initializers")
23 static PerfGraphRegistry perf_graph_registry_singleton;
24
25 return perf_graph_registry_singleton;
26}
27
32
33unsigned int
34PerfGraphRegistry::registerSection(const std::string & section_name, unsigned int level)
35{
36 return actuallyRegisterSection(section_name, level, "", false);
37}
38
40PerfGraphRegistry::registerSection(const std::string & section_name,
41 unsigned int level,
42 const std::string & live_message,
43 const bool print_dots)
44{
45 if (section_name == "")
46 mooseError("Section name not provided when registering timed section!");
47
48 if (live_message == "")
49 mooseError("Live message not provided when registering timed section!");
50
51 return actuallyRegisterSection(section_name, level, live_message, print_dots);
52}
53
55PerfGraphRegistry::actuallyRegisterSection(const std::string & section_name,
56 unsigned int level,
57 const std::string & live_message,
58 const bool print_dots)
59{
60 const auto create_item = [&section_name, &level, &live_message, &print_dots](const std::size_t id)
61 { return PerfGraphSectionInfo(id, section_name, level, live_message, print_dots); };
62 return registerItem(section_name, create_item);
63}
64
65}
66}
67
68void
69dataStore(std::ostream & stream, moose::internal::PerfGraphSectionInfo & info, void * context)
70{
71 dataStore(stream, info._id, context);
72 dataStore(stream, info._name, context);
73 dataStore(stream, info._level, context);
74 dataStore(stream, info._live_message, context);
75 dataStore(stream, info._print_dots, context);
76}
77
78void
79dataLoad(std::istream & stream, moose::internal::PerfGraphSectionInfo & info, void * context)
80{
81 dataLoad(stream, info._id, context);
82 dataLoad(stream, info._name, context);
83 dataLoad(stream, info._level, context);
84 dataLoad(stream, info._live_message, context);
85 dataLoad(stream, info._print_dots, context);
86}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
unsigned int PerfID
Definition MooseTypes.h:240
void dataStore(std::ostream &stream, moose::internal::PerfGraphSectionInfo &info, void *context)
void dataLoad(std::istream &stream, moose::internal::PerfGraphSectionInfo &info, void *context)
std::size_t registerItem(const std::string &key, CreateItem &create_item)
Registers an item with key key if said key does not exist.
std::size_t id(const std::string &key) const
The place where all timed sections will be stored.
PerfID registerSection(const std::string &section_name, const unsigned int level)
Call to register a named section for timing.
PerfID actuallyRegisterSection(const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true)
The internal function that actually carries out the registration.
Used to hold metadata about the registered sections Note: this is a class instead of a struct because...
PerfGraphRegistry & getPerfGraphRegistry()
Get the global PerfGraphRegistry singleton.