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-2018 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  //- Construct null, 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 
107 } // End namespace Foam
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 // Macros
112 
113 //- Define profiling trigger with specified name and description string
114 // \sa endProfiling
115 #define addProfiling(name,descr) \
116  ::Foam::profilingTrigger profilingTriggerFor##name(descr)
117 
118 //- Define profiling trigger with specified name and description
119 //- corresponding to the compiler-defined function name string
120 // \sa addProfiling
121 // \sa endProfiling
122 #ifdef __GNUC__
123  #define addProfilingInFunction(name) \
124  ::Foam::profilingTrigger profilingTriggerFor##name(__PRETTY_FUNCTION__)
125 #else
126  #define addProfilingInFunction(name) \
127  ::Foam::profilingTrigger profilingTriggerFor##name(__func__)
128 #endif
129 
130 //- Remove profiling with specified name
131 // \sa addProfiling
132 #define endProfiling(name) profilingTriggerFor##name.stop()
133 
134 
135 #endif
136 
137 // ************************************************************************* //
Foam::profilingTrigger::profilingTrigger
profilingTrigger()
Construct null, 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:60
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
addProfiling
#define addProfiling(name, descr)
Define profiling trigger with specified name and description string.
Definition: profilingTrigger.H:114
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:131