profilingInformation.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::profilingInformation
29
30Description
31 Code profiling information in terms of time spent, number of calls etc.
32
33SourceFiles
34 profilingInformation.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef profilingInformation_H
39#define profilingInformation_H
40
41#include "label.H"
42#include "scalar.H"
43#include "string.H"
44
45// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46
47namespace Foam
48{
49
50// Forward Declarations
51class profiling;
52
53/*---------------------------------------------------------------------------*\
54 Class profilingInformation Declaration
55\*---------------------------------------------------------------------------*/
58{
59 // Private Data
60
61 //- Unique id to identify it
62 const label id_;
63
64 //- What this timer does
65 const string description_;
66
67 //- Pointer to the parent object (or self for top-level)
68 profilingInformation* parent_;
69
70 //- Number of times this was called
71 long calls_;
72
73 //- Total time spent
74 scalar totalTime_;
75
76 //- Time spent in children
77 scalar childTime_;
78
79 //- Max memory usage on call.
80 // Only valid when the calling profiling has memInfo active.
81 mutable int maxMem_;
82
83 //- Is this information active or passive (ie, on the stack)?
84 mutable bool active_;
85
86
87protected:
88
89 // Friendship
90
91 //- Allow creation of master-element, setActive etc.
92 friend class profiling;
93
94
95 // Constructors
96
97 //- Default construct - only the master-element
99
100
101 // Protected Member Functions
102
103 //- Mark as being active or passive)
104 void setActive(bool state) const;
105
106 //- No copy construct
108
109 //- No copy assignment
110 void operator=(const profilingInformation&) = delete;
111
112public:
113
114 // Constructors
115
116 //- Construct from components
118 (
120 const string& descr,
121 const label id
122 );
123
124
125 //- Destructor
126 ~profilingInformation() = default;
127
128
129 // Member Functions
130
131 // Access
133 label id() const
134 {
135 return id_;
136 }
138 const string& description() const
139 {
140 return description_;
141 }
144 {
145 return *parent_;
146 }
148 label calls() const
149 {
150 return calls_;
151 }
153 scalar totalTime() const
154 {
155 return totalTime_;
156 }
158 scalar childTime() const
159 {
160 return childTime_;
161 }
163 int maxMem() const
164 {
165 return maxMem_;
166 }
168 bool active() const
169 {
170 return active_;
171 }
172
173
174 // Edit
175
176 //- Update it with a new timing information
177 void update(const scalar elapsedTime);
178
179
180 // Write
181
182 //- Write the profiling times, optionally with additional values
183 // Uses dictionary format.
185 (
186 Ostream& os,
187 const bool offset = false,
188 const scalar elapsedTime = 0,
189 const scalar childTime = 0
190 ) const;
191};
192
193
194// Global Operators
195
196Ostream& operator<<(Ostream& os, const profilingInformation& info);
197
198
199// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200
201} // End namespace Foam
202
203// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204
205
206#endif
207
208// ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Code profiling information in terms of time spent, number of calls etc.
profilingInformation(const profilingInformation &)=delete
No copy construct.
~profilingInformation()=default
Destructor.
void operator=(const profilingInformation &)=delete
No copy assignment.
const string & description() const
profilingInformation()
Default construct - only the master-element.
profilingInformation & parent() const
void setActive(bool state) const
Mark as being active or passive)
Code profiling.
Definition: profiling.H:85
mesh update()
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
runTime write()