Go to the documentation of this file.
54 static const word profilingFileName(
"profiling");
57 static const word blockNameProfiling(
"profiling");
63 {
"profiling", {
"calls",
"totalTime",
"childTime",
"maxMem" } },
64 {
"memInfo", {
"size",
"free" } },
70 int main(
int argc,
char *argv[])
74 "Collect profiling information from processor directories and"
75 " summarize time spent and number of calls as (max avg min) values."
89 #ifdef fileOperation_H
119 <<
"No processor* directories found"
128 databases[0].times(),
132 if (timeDirs.empty())
135 <<
"No times selected" <<
nl <<
endl;
167 profiles[proci].clear();
168 databases[proci].setTime(timeDirs[timei], timei);
173 databases[proci].time(),
178 const IOobject* ioptr = objects.findObject(profilingFileName);
184 profiles[proci] =
dict;
203 Info<<
"found " << nDict <<
"/" << nProcs
204 <<
" profiling files" <<
nl <<
endl;
227 "summarized (max avg min) values from "
238 const entry& mainEntry = mainIter();
245 !processing.found(level1Name)
247 || mainEntry.
dict().empty()
253 const wordList& tags = processing[level1Name];
270 const bool hasDictEntries
280 level2Names = {level1Name};
287 for (
const word& level2Name : level2Names)
291 for (
const word& tag : tags)
293 stats(tag).reserve(nProcs);
302 if (inDictPtr && hasDictEntries)
305 inDictPtr = inDictPtr->
findDict(level2Name);
315 for (
const word& tag : tags)
324 stats(tag).append(val);
329 if (nEntry != nProcs)
339 outputDict.
add(level2Name, level1Dict.
subDict(level2Name));
340 outDictPtr = outputDict.
findDict(level2Name);
345 summary.
add(level1Name, level1Dict,
true);
346 outDictPtr = &outputDict;
354 const word key(
"description");
361 outSubDict.
set(key, val);
367 for (
const word& tag : tags)
371 if (lst.size() == nProcs)
374 const scalar avg =
sum(lst) / nProcs;
376 if (lst.first() != lst.last())
383 lst.last(), avg, lst.first()
395 mkDir(summary.path());
399 summary.writeHeader(os);
400 summary.writeData(os);
401 summary.writeEndDivider(os);
403 Info<<
"Wrote to " << outputName <<
nl <<
endl;
A keyword and a list of tokens is an 'entry'.
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling words, derived from Foam::string.
A class for handling file names.
const keyType & keyword() const
Return keyword.
static word timeName(const scalar t, const int precision=precision_)
static void addNote(const string ¬e)
Add extra notes for the usage information.
instantList select(const instantList ×) const
Select a list of Time values that are within the ranges.
const fileOperation & fileHandler()
Get current file handler.
Ostream & endl(Ostream &os)
Add newline and flush stream.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
static word controlDictName
The default control dictionary name (normally "controlDict")
const fileName & rootPath() const
Return root path.
#define forAll(list, i)
Loop across all elements in list.
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
virtual bool isDict() const
Return true if this entry is a dictionary.
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
static word outputPrefix
Directory prefix.
fileName path() const
Return the full path to the (processor local) case.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
List of IOobjects with searching and retrieving facilities.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Output to file stream, using an OSstream.
bool isDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Check if entry is found and is a sub-dictionary.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
fileName path() const
Return path.
forAllConstIters(mixture.phases(), phase)
void clear()
Clear all entries from table.
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
Encapsulation of natural order sorting for algorithms.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
const fileName & caseName() const
Return case name (parallel run) or global case (serial run)
static void noParallel()
Remove the parallel options.
Foam::argList args(argc, argv)
bool mkDir(const fileName &pathName, mode_t mode=0777)
Make a directory and return an error if it could not be created.
wordList sortedToc() const
Return the sorted table of contents.
#define WarningInFunction
Report a warning using Foam::Warning.
bool removeEnd(const std::string &text)
Remove the given text from the end of the string.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
bool isDir(const fileName &name, const bool followLink=true)
Does the name exist as a DIRECTORY in the file system?