Go to the documentation of this file.
39 std::unique_ptr<Foam::profiling> Foam::profiling::singleton_(
nullptr);
55 children_.resize(pool_.size());
56 children_.last().clear();
68 const label parentId = parent->
id();
70 for (Information* child : children_[parentId])
72 if (descr == child->description())
78 Information* info =
new Information(parent, descr, pool_.size());
81 children_.resize(pool_.size());
82 children_.last().clear();
83 children_[parentId].append(info);
99 Information *info = stack_.remove();
103 info->setActive(
false);
113 return allowed && singleton_;
127 return singleton_->writeData(
os);
138 return singleton_->regIOobject::write();
147 const IOobject& ioObj,
151 if (allowed && !singleton_)
153 singleton_.reset(
new profiling(ioObj, owner));
160 const dictionary&
dict,
161 const IOobject& ioObj,
165 if (allowed && !singleton_)
174 if (singleton_ && &owner == &(singleton_->owner_))
176 singleton_.reset(
nullptr);
183 Information *info =
nullptr;
187 Information *parent = singleton_->stack_.last();
189 info = singleton_->create(parent, descr);
190 singleton_->beginTimer(info);
192 if (singleton_->memInfo_)
197 singleton_->memInfo_->update().size()
208 if (active() && info)
210 Information *top = singleton_->endTimer();
212 if (info->id() != top->id())
215 <<
"Profiling information to unstack has different id than"
216 <<
" the top of the profiling stack" <<
nl
217 <<
" info: " << info->id() <<
" (" << info->description()
219 <<
" top: " << top->id() <<
" (" << top->description()
229 Foam::profiling::profiling
233 const bool allEnabled
248 sysInfo_.reset(
new profilingSysInfo);
249 cpuInfo_.reset(
new cpuInfo);
250 memInfo_.reset(
new memInfo);
260 Foam::profiling::profiling
269 if (
dict.getOrDefault(
"sysInfo",
false))
273 if (
dict.getOrDefault(
"cpuInfo",
false))
275 cpuInfo_.reset(
new cpuInfo);
277 if (
dict.getOrDefault(
"memInfo",
false))
288 if (
this == singleton_.get())
290 singleton_.reset(
nullptr);
305 return stack_.size();
315 const label nstack = stack_.size();
319 for (label stacki=0; stacki < nstack; ++stacki)
321 elapsed[stacki] = (now - times_[stacki]);
328 for (label stacki=0; stacki < nstack; ++stacki)
330 if (stacki)
os <<
nl;
332 stack_[stacki]->write
342 for (
const Information& info : pool_)
void resize(const label len)
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
bitSet create(const label n, const labelHashSet &locations, const bool on=true)
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Ostream & endl(Ostream &os)
virtual Ostream & beginBlock(const keyType &kw)
InfoProxy< IOobject > info() const
bool good() const noexcept
clockValue elapsed() const
int infoSwitch(const char *name, const int deflt=0)
static void stop(const Time &owner)
The IOstreamOption is a simple container for options an IOstream can normally have.
const Time & owner() const
label max(const labelHashSet &set, label maxValue=labelMin)
General CPU characteristics.
General system information useful for profiling.
virtual Ostream & endBlock()
Access to high-resolution clock value with some basic operations. Used to calculate time durations,...
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
OBJstream os(runTime.globalPath()/outputName)
Memory usage information for the current process, and the system memory that is free.
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
virtual bool write(const token &tok)=0
errorManip< error > abort(error &err)
static void unstack(const profilingInformation *info)
void beginTimer(Information *info)
static void initialize(const IOobject &ioObj, const Time &owner)
virtual bool writeData(Ostream &os) const
@ ASCII
"ascii" (normal default)
#define FatalErrorInFunction
static profilingInformation * New(const string &descr)
label size() const noexcept
static bool print(Ostream &os)
Ostream & writeEntry(const keyType &key, const T &value)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
profilingInformation Information
virtual bool writeObject(IOstreamOption, const bool valid) const