3 # Lists the profiling information in time directories (uniform/profilingInfo)
4 # in a human readable form
6 from PyFoam
.RunDictionary
.ParsedParameterFile
import ParsedParameterFile
9 pf
=ParsedParameterFile(sys
.argv
[1],
10 treatBinaryAsASCII
=True)
16 for p
in pf
["profilingInfo"]:
18 print "Duplicate definition of",p
["id"]
20 if p
["description"][0]=='"':
21 p
["description"]=p
["description"][1:]
22 if p
["description"][-1]=='"':
23 p
["description"]=p
["description"][:-1]
27 if p
["parentId"] in children
:
28 children
[p
["parentId"]].append(p
["id"])
30 children
[p
["parentId"]]=[p
["id"]]
33 print "Two root elements"
40 return max([depth(j
) for j
in children
[i
]])+1
44 #make sure that children are printed in the correct order
54 maxi
=len(data
[i
]["description"])
56 maxi
=max(maxi
,max([nameLen(j
,d
+1) for j
in children
[i
]]))
61 format
=" %5.1f%% (%5.1f%%) - %5.1f%% | %8d %9.4gs %9.4gs"
62 totalTime
=data
[root
]["totalTime"]
64 header
=" "*(maxLen
)+" | parent (total ) - self | calls total self "
71 result
+=" "*(depths
[i
]-1)
74 result
+=data
[i
]["description"]
75 result
+=" "*(maxLen
-len(result
)+1)+"| "
77 parentTime
=data
[i
]["totalTime"]
78 if "parentId" in data
[i
]:
79 parentTime
=data
[data
[i
]["parentId"]]["totalTime"]
81 tt
=data
[i
]["totalTime"]
82 ct
=data
[i
]["childTime"]
84 result
+=format
% (100*tt
/parentTime
,
85 100*(tt
-ct
)/totalTime
,