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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::profilingTrigger
29
30Description
31 Triggers for starting/stopping code profiling.
32
33SourceFiles
34 profilingTrigger.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef profilingTrigger_H
39#define profilingTrigger_H
40
41#include "string.H"
42
43// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45namespace Foam
46{
47
48// Forward Declarations
49class profilingInformation;
50
51/*---------------------------------------------------------------------------*\
52 Class profilingTrigger Declaration
53\*---------------------------------------------------------------------------*/
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
72public:
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// ************************************************************************* //
Code profiling information in terms of time spent, number of calls etc.
Triggers for starting/stopping code profiling.
void stop()
Stop triggered profiling.
bool running() const
True if the triggered profiling is active.
~profilingTrigger()
Destructor.
profilingTrigger()
Default construct, no profiling trigger.
Namespace for OpenFOAM.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
#define endProfiling(name)
Remove profiling with specified name.
#define addProfiling(name, descr)
Define profiling trigger with specified name and description string.