profilingTrigger.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2009-2016 Bernhard Gschaider
9  Copyright (C) 2016-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::profilingTrigger
29 
30 Description
31  Triggers for starting/stopping code profiling.
32 
33 SourceFiles
34  profilingTrigger.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef profilingTrigger_H
39 #define profilingTrigger_H
40 
41 #include "string.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // Forward Declarations
49 class profilingInformation;
50 
51 /*---------------------------------------------------------------------------*\
52  Class profilingTrigger Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class profilingTrigger
56 {
57  // Private Data Members
58 
59  //- The profiling information
61 
62 
63  // Private Member Functions
64 
65  //- No copy construct
66  profilingTrigger(const profilingTrigger&) = delete;
67 
68  //- No copy assignment
69  void operator=(const profilingTrigger&) = delete;
70 
71 
72 public:
73 
74  // Constructors
75 
76  //- Default construct, no profiling trigger
78 
79  //- Construct profiling with given description.
80  // Descriptions beginning with 'application::' are reserved for
81  // internal use.
82  profilingTrigger(const char* name);
83 
84  //- Construct profiling with given description.
85  // Descriptions beginning with 'application::' are reserved for
86  // internal use.
87  profilingTrigger(const string& name);
88 
89 
90  //- Destructor
92 
93 
94  // Member Functions
95 
96  //- True if the triggered profiling is active
97  bool running() const;
98 
99  //- Stop triggered profiling
100  void stop();
101 };
102 
103 
104 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
105 
106 } // End namespace Foam
107 
108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 
110 // Macros
111 
112 //- Define profiling trigger with specified name and description string
113 // \sa endProfiling
114 #define addProfiling(name,descr) \
115  ::Foam::profilingTrigger profilingTriggerFor##name(descr)
116 
117 //- Define profiling trigger with specified name and description
118 //- corresponding to the compiler-defined function name string
119 // \sa addProfiling
120 // \sa endProfiling
121 #ifdef __GNUC__
122  #define addProfilingInFunction(name) \
123  ::Foam::profilingTrigger profilingTriggerFor##name(__PRETTY_FUNCTION__)
124 #else
125  #define addProfilingInFunction(name) \
126  ::Foam::profilingTrigger profilingTriggerFor##name(__func__)
127 #endif
128 
129 //- Remove profiling with specified name
130 // \sa addProfiling
131 #define endProfiling(name) profilingTriggerFor##name.stop()
132 
133 
134 #endif
135 
136 // ************************************************************************* //
Foam::profilingTrigger::profilingTrigger
profilingTrigger()
Default construct, no profiling trigger.
Definition: profilingTrigger.C:35
Foam::profilingTrigger::stop
void stop()
Stop triggered profiling.
Definition: profilingTrigger.C:69
string.H
Foam::profilingTrigger::running
bool running() const
True if the triggered profiling is active.
Definition: profilingTrigger.C:63
Foam::profilingTrigger::~profilingTrigger
~profilingTrigger()
Destructor.
Definition: profilingTrigger.C:55
Foam::profilingInformation
Code profiling information in terms of time spent, number of calls etc.
Definition: profilingInformation.H:56
addProfiling
#define addProfiling(name, descr)
Define profiling trigger with specified name and description string.
Definition: profilingTrigger.H:113
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::profilingTrigger
Triggers for starting/stopping code profiling.
Definition: profilingTrigger.H:54
endProfiling
#define endProfiling(name)
Remove profiling with specified name.
Definition: profilingTrigger.H:130
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59