From 1ef994d85cd2a13305ee8e933f26ebea1ed48f93 Mon Sep 17 00:00:00 2001 From: "Bernhard F.W. Gschaider" Date: Tue, 20 Aug 2013 00:30:38 +0200 Subject: [PATCH] Adding some comments to profiling-stuff --HG-- branch : bgschaid/minorAdditionsBranch --- bin/listProfileInformation.py | 20 ++++++++++++++------ src/OpenFOAM/global/Profiling/Profiling.H | 8 ++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/bin/listProfileInformation.py b/bin/listProfileInformation.py index 993c03765..1b772cf1a 100755 --- a/bin/listProfileInformation.py +++ b/bin/listProfileInformation.py @@ -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 import sys @@ -14,6 +17,11 @@ for p in pf["profilingInfo"]: if p["id"] in data: print "Duplicate definition of",p["id"] 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 if "parentId" in p: if p["parentId"] in children: @@ -36,7 +44,7 @@ def depth(i): #make sure that children are printed in the correct order for i in children: children[i].sort() - + maxdepth=depth(root) depths={} @@ -46,7 +54,7 @@ def nameLen(i,d=0): maxi=len(data[i]["description"]) if i in children: maxi=max(maxi,max([nameLen(j,d+1) for j in children[i]])) - return maxi+2 + return maxi+3 maxLen=nameLen(root) @@ -62,7 +70,7 @@ def printItem(i): if depths[i]>1: result+=" "*(depths[i]-1) if depths[i]>0: - result+="|-" + result+="|- " result+=data[i]["description"] result+=" "*(maxLen-len(result)+1)+"| " @@ -72,7 +80,7 @@ def printItem(i): tt=data[i]["totalTime"] ct=data[i]["childTime"] - + result+=format % (100*tt/parentTime, 100*(tt-ct)/totalTime, 100*(tt-ct)/tt, @@ -83,5 +91,5 @@ def printItem(i): if i in children: for c in children[i]: printItem(c) - + printItem(root) diff --git a/src/OpenFOAM/global/Profiling/Profiling.H b/src/OpenFOAM/global/Profiling/Profiling.H index 90d8589b8..f51c8451e 100644 --- a/src/OpenFOAM/global/Profiling/Profiling.H +++ b/src/OpenFOAM/global/Profiling/Profiling.H @@ -27,6 +27,9 @@ Class Description 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 \*---------------------------------------------------------------------------*/ @@ -36,9 +39,14 @@ SourceFiles #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) + // Use this if a description with spaces, colons etc should be added #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() // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //