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."
104 args.allowFunctionObjects(),
113 <<
"No processor* directories found"
122 databases[0].times(),
126 if (timeDirs.
empty())
129 <<
"No times selected" <<
nl <<
endl;
136 List<dictionary> profiles(nProcs);
142 runTime.setTime(timeDirs[timei], timei);
161 profiles[proci].clear();
162 databases[proci].setTime(timeDirs[timei], timei);
167 databases[proci].time(),
172 const IOobject* ioptr = objects.findObject(profilingFileName);
178 profiles[proci] =
dict;
197 Info<<
"found " << nDict <<
"/" << nProcs
198 <<
" profiling files" <<
nl <<
endl;
221 "summarized (max avg min) values from "
232 const entry& mainEntry = mainIter();
239 !processing.
found(level1Name)
247 const wordList& tags = processing[level1Name];
264 const bool hasDictEntries
274 level2Names = {level1Name};
281 for (
const word& level2Name : level2Names)
285 for (
const word& tag : tags)
296 if (inDictPtr && hasDictEntries)
299 inDictPtr = inDictPtr->
findDict(level2Name);
309 for (
const word& tag : tags)
318 stats(tag).append(val);
323 if (nEntry != nProcs)
333 outputDict.
add(level2Name, level1Dict.
subDict(level2Name));
334 outDictPtr = outputDict.
findDict(level2Name);
339 summary.add(level1Name, level1Dict,
true);
340 outDictPtr = &outputDict;
355 outSubDict.
set(key, val);
361 for (
const word& tag : tags)
365 if (lst.
size() == nProcs)
368 const scalar avg =
sum(lst) / nProcs;
389 mkDir(summary.path());
393 summary.writeHeader(
os);
394 summary.writeData(
os);
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
bool empty() const noexcept
True if the list is empty.
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.
bool found(const Key &key) const
Same as contains().
void reserve(label numEntries)
Reserve space for at least the specified number of elements (not the number of buckets) and regenerat...
void clear()
Remove 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. Implemented as a HashTable,...
@ NO_REGISTER
Do not request registration (bool: false).
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
static Ostream & writeEndDivider(Ostream &os)
Write the standard end file divider.
Output to file stream as an OSstream, normally using std::ofstream for the actual output.
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.
static word controlDictName
The default control dictionary name (normally "controlDict").
T * first()
The first entry in the list.
T & first()
Access first element of the list, position [0].
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void size(const label n)
Older name for setAddressableSize.
T & last()
Access last element of the list, position [size()-1].
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
static void noParallel()
Remove the parallel options.
static void addNote(const string ¬e)
Add extra notes for the usage information.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and it is a dictionary) otherwise return nullptr...
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
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
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
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, otherwise Fatal.
A class for handling file names.
static word outputPrefix
Directory prefix.
bool removeEnd(const std::string &text)
Remove the given text from the end of the string.
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
instantList select(const instantList ×) const
Select a list of Time values that are within the ranges.
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.
constexpr auto key(const Type &t) noexcept
Helper function to return the enum value.
List< word > wordList
List of word.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler().
messageStream Info
Information stream (stdout output on master, null elsewhere).
List< instant > instantList
List of instants.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void sort(UList< T > &list)
Sort the list.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::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.