www.mooseframework.org
PerfGraphOutput.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 // Moose includes
11 #include "PerfGraphOutput.h"
12 #include "MooseApp.h"
15 #include "ConsoleUtils.h"
16 
18 
21 {
22  // Get the base class parameters
24 
25  // Hide/show variable output options
26  params.addParam<std::vector<VariableName>>(
27  "hide",
28  "A list of the variables and postprocessors that should NOT be output to the"
29  "file (may include Variables, ScalarVariables, and Postprocessor names).");
30 
31  params.set<ExecFlagEnum>("execute_on") = {EXEC_FINAL};
32 
33  params.addParam<unsigned int>(
34  "level", 1, "The level of detail to output. Higher levels will yield more detail.");
35 
36  params.addParam<bool>("heaviest_branch",
37  false,
38  "Whether or not to print out the trace through the code that took the "
39  "longest amount of time");
40 
41  params.addParam<unsigned int>("heaviest_sections",
42  0,
43  "The number of sections to print out showing the parts of the code "
44  "that take the most time. When '0' it won't print at all.");
45 
46  params.addClassDescription("Controls output of the PerfGraph: the performance log for MOOSE");
47 
48  // Return the InputParameters
49  return params;
50 }
51 
53  : Output(parameters),
54  _level(getParam<unsigned int>("level")),
55  _heaviest_branch(getParam<bool>("heaviest_branch")),
56  _heaviest_sections(getParam<unsigned int>("heaviest_sections"))
57 {
58 }
59 
60 bool
62 {
63  // We don't want the Perflog to get dumped at odd times. Ignore the FORCED flag.
65 }
66 
67 void
69 {
70  if (!_app.getParam<bool>("no_timing"))
71  {
72  _console << '\n';
73 
75 
76  if (_heaviest_branch)
78 
81 
82  _console << std::flush;
83  }
84 }
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
ExecFlagEnum _execute_on
The common Execution types; this is used as the default execution type for everything except system i...
Definition: Output.h:197
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
unsigned int _level
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
registerMooseObject("MooseApp", PerfGraphOutput)
virtual void output() override
Overload this function with the desired output activities.
static InputParameters validParams()
Based class for output objects.
Definition: Output.h:43
bool contains(const std::string &value) const
Contains methods for seeing if a value is in the MultiMooseEnum.
ExecFlagType _current_execute_flag
Current execute on flag.
Definition: Output.h:205
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:84
virtual bool shouldOutput() override
Handles logic for determining if a step should be output.
void print(const ConsoleStream &console, unsigned int level)
Print the tree out.
Definition: PerfGraph.C:402
const T & getParam(const std::string &name)
Retrieve a parameter for the object.
Definition: MooseApp.h:1465
void printHeaviestBranch(const ConsoleStream &console)
Print out the heaviest branch through the tree.
Definition: PerfGraph.C:409
unsigned int _heaviest_sections
PerfGraph & perfGraph()
Get the PerfGraph.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump...
PerfGraphOutput(const InputParameters &parameters)
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
Class for output information regarding Controls to the screen.
void printHeaviestSections(const ConsoleStream &console, const unsigned int num_sections)
Print out the heaviest sections that were timed.
Definition: PerfGraph.C:416
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
const ExecFlagType EXEC_FINAL
Definition: Moose.C:38
static InputParameters validParams()
Definition: Output.C:32
void ErrorVector unsigned int