Adding some comments to profiling-stuff

--HG--
branch : bgschaid/minorAdditionsBranch
This commit is contained in:
Bernhard F.W. Gschaider 2013-08-20 00:30:38 +02:00
parent 4aaa1d47e6
commit 1ef994d85c
2 changed files with 22 additions and 6 deletions

View file

@ -1,4 +1,7 @@
#! /usr/bin/python #! /usr/bin/env python
# Lists the profiling information in time directories (uniform/profilingInfo)
# in a human readable form
from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile from PyFoam.RunDictionary.ParsedParameterFile import ParsedParameterFile
import sys import sys
@ -14,6 +17,11 @@ for p in pf["profilingInfo"]:
if p["id"] in data: if p["id"] in data:
print "Duplicate definition of",p["id"] print "Duplicate definition of",p["id"]
sys.exit(-1) sys.exit(-1)
if p["description"][0]=='"':
p["description"]=p["description"][1:]
if p["description"][-1]=='"':
p["description"]=p["description"][:-1]
data[p["id"]]=p data[p["id"]]=p
if "parentId" in p: if "parentId" in p:
if p["parentId"] in children: if p["parentId"] in children:
@ -46,7 +54,7 @@ def nameLen(i,d=0):
maxi=len(data[i]["description"]) maxi=len(data[i]["description"])
if i in children: if i in children:
maxi=max(maxi,max([nameLen(j,d+1) for j in children[i]])) maxi=max(maxi,max([nameLen(j,d+1) for j in children[i]]))
return maxi+2 return maxi+3
maxLen=nameLen(root) maxLen=nameLen(root)
@ -62,7 +70,7 @@ def printItem(i):
if depths[i]>1: if depths[i]>1:
result+=" "*(depths[i]-1) result+=" "*(depths[i]-1)
if depths[i]>0: if depths[i]>0:
result+="|-" result+="|- "
result+=data[i]["description"] result+=data[i]["description"]
result+=" "*(maxLen-len(result)+1)+"| " result+=" "*(maxLen-len(result)+1)+"| "

View file

@ -27,6 +27,9 @@ Class
Description Description
Add everything necessary for Profiling plus a macro Add everything necessary for Profiling plus a macro
Originally proposed in
http://www.cfd-online.com/Forums/openfoam-bugs/64081-feature-proposal-application-level-profiling.html
SourceFiles SourceFiles
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -36,9 +39,14 @@ SourceFiles
#include "ProfilingTrigger.H" #include "ProfilingTrigger.H"
// to be used at the beginning of a section to be profiled
// profiling ends automatically at the end of a block
#define addProfile(name) Foam::ProfilingTrigger profileTriggerFor##name (#name) #define addProfile(name) Foam::ProfilingTrigger profileTriggerFor##name (#name)
// Use this if a description with spaces, colons etc should be added // Use this if a description with spaces, colons etc should be added
#define addProfile2(name,descr) Foam::ProfilingTrigger profileTriggerFor##name (descr) #define addProfile2(name,descr) Foam::ProfilingTrigger profileTriggerFor##name (descr)
// this is only needed if profiling should end before the end of a block
#define endProfile(name) profileTriggerFor##name.stop() #define endProfile(name) profileTriggerFor##name.stop()
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //