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