54static const word profilingFileName(
"profiling");
57static const word blockNameProfiling(
"profiling");
63 {
"profiling", {
"calls",
"totalTime",
"childTime",
"maxMem" } },
64 {
"memInfo", {
"size",
"free" } },
70int 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."
78 timeSelector::addOptions(
true,
true);
79 argList::noParallel();
80 argList::noFunctionObjects();
101 Time::controlDictName,
111 <<
"No processor* directories found"
120 databases[0].times(),
124 if (timeDirs.
empty())
127 <<
"No times selected" <<
nl <<
endl;
140 runTime.setTime(timeDirs[timei], timei);
147 functionObject::outputPrefix,
159 profiles[proci].clear();
160 databases[proci].setTime(timeDirs[timei], timei);
165 databases[proci].time(),
170 const IOobject* ioptr = objects.findObject(profilingFileName);
176 profiles[proci] =
dict;
195 Info<<
"found " << nDict <<
"/" << nProcs
196 <<
" profiling files" <<
nl <<
endl;
219 "summarized (max avg min) values from "
230 const entry& mainEntry = mainIter();
237 !processing.found(level1Name)
239 || mainEntry.
dict().empty()
245 const wordList& tags = processing[level1Name];
262 const bool hasDictEntries
272 level2Names = {level1Name};
279 for (
const word& level2Name : level2Names)
283 for (
const word& tag : tags)
285 stats(tag).reserve(nProcs);
294 if (inDictPtr && hasDictEntries)
297 inDictPtr = inDictPtr->
findDict(level2Name);
307 for (
const word& tag : tags)
316 stats(tag).append(val);
321 if (nEntry != nProcs)
331 outputDict.
add(level2Name, level1Dict.
subDict(level2Name));
332 outDictPtr = outputDict.
findDict(level2Name);
337 summary.
add(level1Name, level1Dict,
true);
338 outDictPtr = &outputDict;
353 outSubDict.
set(key, val);
359 for (
const word& tag : tags)
363 if (lst.
size() == nProcs)
366 const scalar avg =
sum(lst) / nProcs;
387 mkDir(summary.path());
391 summary.writeHeader(
os);
392 summary.writeData(
os);
393 summary.writeEndDivider(
os);
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
A 1D vector of objects of type <T> with a fixed length <N>.
A HashTable similar to std::unordered_map.
void clear()
Clear all entries from table.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
List of IOobjects with searching and retrieving facilities.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Output to file stream, using an OSstream.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
T * first()
The first entry in the list.
T & first()
Return the first element of the list.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
void size(const label n)
Older name for setAddressableSize.
T & last()
Return the last element of the list.
const fileName & rootPath() const noexcept
Return root path.
fileName path() const
Return the full path to the (processor local) case.
const fileName & caseName() const noexcept
Return case name (parallel run) or global case (serial run)
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
wordList sortedToc() const
Return the sorted table of contents.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
A keyword and a list of tokens is an 'entry'.
virtual bool isDict() const noexcept
Return true if this entry is a dictionary.
const keyType & keyword() const noexcept
Return keyword.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
A class for handling file names.
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
bool removeEnd(const std::string &text)
Remove the given text from the end of the string.
A class for handling words, derived from Foam::string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
word outputName("finiteArea-edges.obj")
OBJstream os(runTime.globalPath()/outputName)
#define WarningInFunction
Report a warning using Foam::Warning.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
const fileOperation & fileHandler()
Get current file handler.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
void sort(UList< T > &list)
Sort the list.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
errorManipArg< error, int > exit(error &err, const int errNo=1)
constexpr char nl
The newline '\n' character (0x0a)
Foam::argList args(argc, argv)
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Encapsulation of natural order sorting for algorithms.