LCOV - code coverage report
Current view: top level - src/outputs - PerfGraphOutput.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31405 (292dce) with base fef103 Lines: 30 30 100.0 %
Date: 2025-09-04 07:52:05 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      137745 : PerfGraphOutput::validParams()
      21             : {
      22             :   // Get the base class parameters
      23      137745 :   InputParameters params = Output::validParams();
      24             : 
      25             :   // Hide/show variable output options
      26      413235 :   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      413235 :   params.set<ExecFlagEnum>("execute_on") = {EXEC_FINAL};
      32             : 
      33      413235 :   params.addParam<unsigned int>(
      34      275490 :       "level", 1, "The level of detail to output.  Higher levels will yield more detail.");
      35             : 
      36      413235 :   params.addParam<bool>("heaviest_branch",
      37      275490 :                         false,
      38             :                         "Whether or not to print out the trace through the code that took the "
      39             :                         "longest amount of time");
      40             : 
      41      413235 :   params.addParam<unsigned int>("heaviest_sections",
      42      275490 :                                 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      137745 :   params.addClassDescription("Controls output of the PerfGraph: the performance log for MOOSE");
      47             : 
      48             :   // Return the InputParameters
      49      137745 :   return params;
      50      137745 : }
      51             : 
      52       58918 : PerfGraphOutput::PerfGraphOutput(const InputParameters & parameters)
      53             :   : Output(parameters),
      54       58918 :     _level(getParam<unsigned int>("level")),
      55      117836 :     _heaviest_branch(getParam<bool>("heaviest_branch")),
      56      176754 :     _heaviest_sections(getParam<unsigned int>("heaviest_sections"))
      57             : {
      58       58918 : }
      59             : 
      60             : bool
      61     1252782 : PerfGraphOutput::shouldOutput()
      62             : {
      63             :   // We don't want the Perflog to get dumped at odd times. Ignore the FORCED flag.
      64     1252782 :   return _execute_on.isValueSet(_current_execute_flag);
      65             : }
      66             : 
      67             : void
      68       53021 : PerfGraphOutput::output()
      69             : {
      70      159063 :   if (!_app.getParam<bool>("no_timing"))
      71             :   {
      72       53021 :     _console << '\n';
      73             : 
      74       53021 :     perfGraph().print(_console, _level);
      75             : 
      76       53021 :     if (_heaviest_branch)
      77          22 :       perfGraph().printHeaviestBranch(_console);
      78             : 
      79       53021 :     if (_heaviest_sections)
      80          22 :       perfGraph().printHeaviestSections(_console, _heaviest_sections);
      81             : 
      82       53021 :     _console << std::flush;
      83             :   }
      84       53021 : }

Generated by: LCOV version 1.14