Line data Source code
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 :
14 : namespace moose
15 : {
16 : namespace internal
17 : {
18 :
19 : PerfGraphRegistry &
20 190507005 : getPerfGraphRegistry()
21 : {
22 : // In C++11 this is even thread safe! (Lookup "Static Initializers")
23 190507005 : static PerfGraphRegistry perf_graph_registry_singleton;
24 :
25 190507005 : return perf_graph_registry_singleton;
26 : }
27 :
28 51173 : PerfGraphRegistry::PerfGraphRegistry()
29 51173 : : GeneralRegistry<std::string, PerfGraphSectionInfo>("PerfGraphRegistry")
30 : {
31 51173 : }
32 :
33 : unsigned int
34 4886351 : PerfGraphRegistry::registerSection(const std::string & section_name, unsigned int level)
35 : {
36 4886351 : return actuallyRegisterSection(section_name, level, "", false);
37 : }
38 :
39 : PerfID
40 3643111 : PerfGraphRegistry::registerSection(const std::string & section_name,
41 : unsigned int level,
42 : const std::string & live_message,
43 : const bool print_dots)
44 : {
45 3643111 : if (section_name == "")
46 4 : mooseError("Section name not provided when registering timed section!");
47 :
48 3643107 : if (live_message == "")
49 4 : mooseError("Live message not provided when registering timed section!");
50 :
51 3643103 : return actuallyRegisterSection(section_name, level, live_message, print_dots);
52 : }
53 :
54 : PerfID
55 8529454 : PerfGraphRegistry::actuallyRegisterSection(const std::string & section_name,
56 : unsigned int level,
57 : const std::string & live_message,
58 : const bool print_dots)
59 : {
60 6624535 : const auto create_item = [§ion_name, &level, &live_message, &print_dots](const std::size_t id)
61 6624535 : { return PerfGraphSectionInfo(id, section_name, level, live_message, print_dots); };
62 8529454 : return registerItem(section_name, create_item);
63 : }
64 :
65 : }
66 : }
67 :
68 : void
69 6487738 : dataStore(std::ostream & stream, moose::internal::PerfGraphSectionInfo & info, void * context)
70 : {
71 6487738 : dataStore(stream, info._id, context);
72 6487738 : dataStore(stream, info._name, context);
73 6487738 : dataStore(stream, info._level, context);
74 6487738 : dataStore(stream, info._live_message, context);
75 6487738 : dataStore(stream, info._print_dots, context);
76 6487738 : }
77 :
78 : void
79 2037711 : dataLoad(std::istream & stream, moose::internal::PerfGraphSectionInfo & info, void * context)
80 : {
81 2037711 : dataLoad(stream, info._id, context);
82 2037711 : dataLoad(stream, info._name, context);
83 2037711 : dataLoad(stream, info._level, context);
84 2037711 : dataLoad(stream, info._live_message, context);
85 2037711 : dataLoad(stream, info._print_dots, context);
86 2037711 : }
|