www.mooseframework.org
src
postprocessors
PerformanceData.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
#include "
PerformanceData.h
"
11
12
#include "
FEProblem.h
"
13
#include "
SubProblem.h
"
14
15
registerMooseObjectReplaced
(
"MooseApp"
,
PerformanceData
,
"02/01/2019 00:00"
,
PerfGraphData
);
16
17
defineLegacyParams
(
PerformanceData
);
18
19
InputParameters
20
PerformanceData::validParams
()
21
{
22
InputParameters
params =
GeneralPostprocessor::validParams
();
23
24
MooseEnum
column_options(
"n_calls total_time average_time total_time_with_sub "
25
"average_time_with_sub percent_of_active_time "
26
"percent_of_active_time_with_sub"
,
27
"total_time_with_sub"
);
28
params.
addParam
<
MooseEnum
>(
29
"column"
, column_options,
"The column you want the value of (Default: total_time_with_sub)."
);
30
31
MooseEnum
common_categories(
"Application Execution Output Setup Utility"
,
"Execution"
,
true
);
32
params.
addParam
<
MooseEnum
>(
"category"
, common_categories,
"The category for the event"
);
33
34
MooseEnum
common_events(
"ACTIVE ALIVE solve() compute_residual() compute_jacobian()"
,
""
,
true
);
35
params.
addRequiredParam
<
MooseEnum
>(
36
"event"
,
37
common_events,
38
"The name or \"label\" of the event. Must match event name exactly "
39
"including parenthesis if applicable. (\"ALIVE\" and \"ACTIVE\" are "
40
"also valid events, category and column are ignored for these "
41
"cases)."
);
42
43
params.
addClassDescription
(
"Provides programmatic access to Performance Log Data"
);
44
return
params;
45
}
46
47
PerformanceData::PerformanceData
(
const
InputParameters
& parameters)
48
:
GeneralPostprocessor
(parameters),
49
_column(getParam<
MooseEnum
>(
"column"
).getEnum<
PerfLogCols
>()),
50
_category(getParam<
MooseEnum
>(
"category"
)),
51
_event(getParam<
MooseEnum
>(
"event"
))
52
{
53
// Notify the OutputWarehouse that logging has been requested
54
_app
.
getOutputWarehouse
().
setLoggingRequested
();
55
}
56
57
Real
58
PerformanceData::getValue
()
59
{
60
if
(
_event
==
"ALIVE"
)
61
return
Moose::perf_log
.get_elapsed_time();
62
63
Real total_time =
Moose::perf_log
.get_active_time();
64
if
(
_event
==
"ACTIVE"
)
65
return
total_time;
66
67
PerfData perf_data =
Moose::perf_log
.get_perf_data(
_event
,
_category
);
68
if
(perf_data.count == 0)
69
return
0.0;
70
71
switch
(
_column
)
72
{
73
case
N_CALLS
:
74
return
perf_data.count;
75
case
TOTAL_TIME
:
76
return
perf_data.tot_time;
77
case
AVERAGE_TIME
:
78
return
perf_data.tot_time / static_cast<double>(perf_data.count);
79
case
TOTAL_TIME_WITH_SUB
:
80
return
perf_data.tot_time_incl_sub;
81
case
AVERAGE_TIME_WITH_SUB
:
82
return
perf_data.tot_time_incl_sub / static_cast<double>(perf_data.count);
83
case
PERCENT_OF_ACTIVE_TIME
:
84
return
(total_time != 0.) ? perf_data.tot_time / total_time * 100. : 0.;
85
case
PERCENT_OF_ACTIVE_TIME_WITH_SUB
:
86
return
(total_time != 0.) ? perf_data.tot_time_incl_sub / total_time * 100. : 0.;
87
default
:
88
mooseError
(
"Invalid column!"
);
89
}
90
91
return
0;
92
}
Moose::perf_log
PerfLog perf_log
Perflog to be used by applications.
PerformanceData.h
FEProblem.h
PerformanceData::getValue
virtual Real getValue() override
This will return the elapsed wall time.
Definition:
PerformanceData.C:58
MooseApp::getOutputWarehouse
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition:
MooseApp.C:1122
defineLegacyParams
defineLegacyParams(PerformanceData)
MooseObject::mooseError
void mooseError(Args &&... args) const
Definition:
MooseObject.h:141
PerformanceData::TOTAL_TIME
Definition:
PerformanceData.h:38
GeneralPostprocessor::validParams
static InputParameters validParams()
Definition:
GeneralPostprocessor.C:15
MooseEnum
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition:
MooseEnum.h:31
PerformanceData::TOTAL_TIME_WITH_SUB
Definition:
PerformanceData.h:40
InputParameters::addParam
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.
Definition:
InputParameters.h:1198
PerformanceData::AVERAGE_TIME_WITH_SUB
Definition:
PerformanceData.h:41
PerformanceData::_event
MooseEnum _event
Definition:
PerformanceData.h:50
PerformanceData::AVERAGE_TIME
Definition:
PerformanceData.h:39
InputParameters
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
Definition:
InputParameters.h:53
PerformanceData::PERCENT_OF_ACTIVE_TIME
Definition:
PerformanceData.h:42
registerMooseObjectReplaced
registerMooseObjectReplaced("MooseApp", PerformanceData, "02/01/2019 00:00", PerfGraphData)
PerformanceData::validParams
static InputParameters validParams()
Definition:
PerformanceData.C:20
PerformanceData::PERCENT_OF_ACTIVE_TIME_WITH_SUB
Definition:
PerformanceData.h:43
GeneralPostprocessor
This class is here to combine the Postprocessor interface and the base class Postprocessor object alo...
Definition:
GeneralPostprocessor.h:27
InputParameters::addClassDescription
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.
Definition:
InputParameters.C:70
SubProblem.h
PerfGraphData
Definition:
PerfGraphData.h:27
PerformanceData
Definition:
PerformanceData.h:20
PerformanceData::_column
PerfLogCols _column
Definition:
PerformanceData.h:47
PerformanceData::PerformanceData
PerformanceData(const InputParameters ¶meters)
Definition:
PerformanceData.C:47
PerformanceData::PerfLogCols
PerfLogCols
Definition:
PerformanceData.h:35
PerformanceData::N_CALLS
Definition:
PerformanceData.h:37
InputParameters::addRequiredParam
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...
Definition:
InputParameters.h:1176
MooseObject::_app
MooseApp & _app
The MooseApp this object is associated with.
Definition:
MooseObject.h:172
OutputWarehouse::setLoggingRequested
void setLoggingRequested()
Sets a Boolean indicating that at least one object is requesting performance logging in this applicat...
Definition:
OutputWarehouse.h:189
PerformanceData::_category
MooseEnum _category
Definition:
PerformanceData.h:49
Generated on Sat Jan 25 2020 11:56:11 for www.mooseframework.org by
1.8.16