www.mooseframework.org
PerformanceData.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #include "PerformanceData.h"
16 
17 #include "FEProblem.h"
18 #include "SubProblem.h"
19 
20 template <>
23 {
25 
26  MooseEnum column_options("n_calls total_time average_time total_time_with_sub "
27  "average_time_with_sub percent_of_active_time "
28  "percent_of_active_time_with_sub",
29  "total_time_with_sub");
30  params.addParam<MooseEnum>(
31  "column", column_options, "The column you want the value of (Default: total_time_with_sub).");
32 
33  MooseEnum common_categories("Application Execution Output Setup Utility", "Execution", true);
34  params.addParam<MooseEnum>("category", common_categories, "The category for the event");
35 
36  MooseEnum common_events("ACTIVE ALIVE solve() compute_residual() compute_jacobian()", "", true);
38  "event",
39  common_events,
40  "The name or \"label\" of the event. Must match event name exactly "
41  "including parenthesis if applicable. (\"ALIVE\" and \"ACTIVE\" are "
42  "also valid events, category and column are ignored for these "
43  "cases).");
44 
45  return params;
46 }
47 
49  : GeneralPostprocessor(parameters),
50  _column(getParam<MooseEnum>("column").getEnum<PerfLogCols>()),
51  _category(getParam<MooseEnum>("category")),
52  _event(getParam<MooseEnum>("event"))
53 {
54  // Notify the OutputWarehouse that logging has been requested
56 }
57 
58 Real
60 {
61  if (_event == "ALIVE")
62  return Moose::perf_log.get_elapsed_time();
63 
64  Real total_time = Moose::perf_log.get_active_time();
65  if (_event == "ACTIVE")
66  return total_time;
67 
68  PerfData perf_data = Moose::perf_log.get_perf_data(_event, _category);
69  if (perf_data.count == 0)
70  return 0.0;
71 
72  switch (_column)
73  {
74  case N_CALLS:
75  return perf_data.count;
76  case TOTAL_TIME:
77  return perf_data.tot_time;
78  case AVERAGE_TIME:
79  return perf_data.tot_time / static_cast<double>(perf_data.count);
81  return perf_data.tot_time_incl_sub;
83  return perf_data.tot_time_incl_sub / static_cast<double>(perf_data.count);
85  return (total_time != 0.) ? perf_data.tot_time / total_time * 100. : 0.;
87  return (total_time != 0.) ? perf_data.tot_time_incl_sub / total_time * 100. : 0.;
88  default:
89  mooseError("Invalid column!");
90  }
91 
92  return 0;
93 }
void setLoggingRequested()
Sets a Boolean indicating that at least one object is requesting performance logging in this applicat...
MooseEnum _category
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters validParams< GeneralPostprocessor >()
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
virtual Real getValue() override
This will return the elapsed wall time.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
PerfLog perf_log
Perflog to be used by applications.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MooseEnum.h:37
InputParameters validParams< PerformanceData >()
MooseApp & _app
The MooseApp this object is associated with.
Definition: MooseObject.h:108
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...
void mooseError(Args &&...args) const
Definition: MooseObject.h:80
PerformanceData(const InputParameters &parameters)
PerfLogCols _column
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition: MooseApp.C:841