1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "profilingInfo.H"
28 #include "dictionary.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 Foam::label Foam::profilingInfo::nextId_(0);
34 Foam::label Foam::profilingInfo::getID()
40 void Foam::profilingInfo::raiseID(label maxVal)
47 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52 Foam::profilingInfo::profilingInfo()
59 description_("application::main"),
64 Foam::profilingInfo::profilingInfo(profilingInfo &parent,const string &descr)
75 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
77 Foam::profilingInfo::~profilingInfo()
81 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83 void Foam::profilingInfo::update(scalar elapsedTimee)
86 totalTime_+=elapsedTimee;
87 if(id()!=parent().id()) {
88 parent_.childTime_+=elapsedTimee;
92 void Foam::profilingInfo::writeWithOffset(Ostream &os,bool offset,scalar time,scalar childTimes) const
97 if(id()!=parent().id()) {
98 tmp.add("parentId",parent().id());
100 tmp.add("description",description());
101 tmp.add("calls",calls()+(offset ? 1 : 0));
102 tmp.add("totalTime",totalTime()+time);
103 tmp.add("childTime",childTime()+childTimes);
104 tmp.add("onStack",onStack());
109 // * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
112 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
114 Foam::Ostream& Foam::operator<<(Ostream& os, const profilingInfo& info)
116 info.writeWithOffset(os);
121 // ************************************************************************* //