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 : // Moose includes 11 : #include "PerfGraphOutput.h" 12 : #include "MooseApp.h" 13 : #include "MooseObjectParameterName.h" 14 : #include "InputParameterWarehouse.h" 15 : #include "ConsoleUtils.h" 16 : 17 : registerMooseObject("MooseApp", PerfGraphOutput); 18 : 19 : InputParameters 20 136077 : PerfGraphOutput::validParams() 21 : { 22 : // Get the base class parameters 23 136077 : InputParameters params = Output::validParams(); 24 : 25 : // Hide/show variable output options 26 136077 : 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 272154 : params.set<ExecFlagEnum>("execute_on") = {EXEC_FINAL}; 32 : 33 408231 : params.addParam<unsigned int>( 34 272154 : "level", 1, "The level of detail to output. Higher levels will yield more detail."); 35 : 36 408231 : params.addParam<bool>("heaviest_branch", 37 272154 : false, 38 : "Whether or not to print out the trace through the code that took the " 39 : "longest amount of time"); 40 : 41 408231 : params.addParam<unsigned int>("heaviest_sections", 42 272154 : 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 136077 : params.addClassDescription("Controls output of the PerfGraph: the performance log for MOOSE"); 47 : 48 : // Return the InputParameters 49 136077 : return params; 50 136077 : } 51 : 52 58147 : PerfGraphOutput::PerfGraphOutput(const InputParameters & parameters) 53 : : Output(parameters), 54 58147 : _level(getParam<unsigned int>("level")), 55 58147 : _heaviest_branch(getParam<bool>("heaviest_branch")), 56 116294 : _heaviest_sections(getParam<unsigned int>("heaviest_sections")) 57 : { 58 58147 : } 59 : 60 : bool 61 1242731 : PerfGraphOutput::shouldOutput() 62 : { 63 : // We don't want the Perflog to get dumped at odd times. Ignore the FORCED flag. 64 1242731 : return _execute_on.isValueSet(_current_execute_flag); 65 : } 66 : 67 : void 68 52252 : PerfGraphOutput::output() 69 : { 70 52252 : if (!_app.getParam<bool>("no_timing")) 71 : { 72 52252 : _console << '\n'; 73 : 74 52252 : perfGraph().print(_console, _level); 75 : 76 52252 : if (_heaviest_branch) 77 22 : perfGraph().printHeaviestBranch(_console); 78 : 79 52252 : if (_heaviest_sections) 80 22 : perfGraph().printHeaviestSections(_console, _heaviest_sections); 81 : 82 52252 : _console << std::flush; 83 : } 84 52252 : }