LCOV - code coverage report
Current view: top level - src/outputs - PerfGraphOutput.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 2bf808 Lines: 30 30 100.0 %
Date: 2025-07-17 01:28:37 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14