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();
72 if (descr == child->description())
81 children_.resize(pool_.size());
82 children_.last().clear();
83 children_[parentId].append(info);
113 return allowed && singleton_;
127 return singleton_->writeData(
os);
138 return singleton_->regIOobject::write();
151 if (allowed && !singleton_)
153 singleton_.reset(
new profiling(ioObj, owner));
165 if (allowed && !singleton_)
174 if (singleton_ && &owner == &(singleton_->owner_))
176 singleton_.reset(
nullptr);
189 info = singleton_->create(parent, descr);
190 singleton_->beginTimer(info);
192 if (singleton_->memInfo_)
197 singleton_->memInfo_->update().size()
208 if (active() && info)
212 if (info->
id() != top->
id())
215 <<
"Profiling information to unstack has different id than"
216 <<
" the top of the profiling stack" <<
nl
229 Foam::profiling::profiling
233 const bool allEnabled
254 this->beginTimer(info);
260 Foam::profiling::profiling
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
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)
Create a bitSet with length n with the specified on locations.
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.
Information * create()
Clear all profiling and restart with new profiling.
static int allowed
Flag if profiling is allowed.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
InfoProxy< IOobject > info() const
Return info proxy.
bool good() const noexcept
True if next operation might succeed.
clockValue elapsed() const
The time duration elapsed until now() since the start point.
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
static void stop(const Time &owner)
Stop profiling, cleanup pool if possible.
static bool active()
True if profiling is allowed and is active.
The IOstreamOption is a simple container for options an IOstream can normally have.
const Time & owner() const
The owner of the profiling.
Information * endTimer()
Remove from stack of active information and update elapsed time.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
~profiling()
Destructor. Top-level clears the singleton.
General CPU characteristics.
General system information useful for profiling.
virtual Ostream & endBlock()
Write end block group.
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
Write using stream options.
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
static void disable()
Disallow profiling by forcing the InfoSwitch off.
errorManip< error > abort(error &err)
static void unstack(const profilingInformation *info)
Remove the information from the top of the stack.
void beginTimer(Information *info)
Add to stack of active information and begin timer datum.
static void initialize(const IOobject &ioObj, const Time &owner)
Singleton to initialize profiling pool, everything enabled.
virtual bool writeData(Ostream &os) const
writeData member function required by regIOobject
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static profilingInformation * New(const string &descr)
Existing or new element on pool, add to stack.
label size() const noexcept
The size of the current stack.
static bool print(Ostream &os)
Print profiling information to specified output.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
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
static clockValue now()
The current clock value from the system.
virtual bool writeObject(IOstreamOption, const bool valid) const
Write as uncompressed ASCII.
static bool writeNow()
Write profiling information now.