14 print(
'{0:<105}'.
format(
'IMPORTANT : PLEASE NOTE THAT THIS SERVICE IS CURRENTLY IN R&D PHASE.'))
15 print(
'{0:<105}'.
format(
' FOR FURTHER INFORMATION/QUERIES PLEASE GET IN TOUCH WITH THE SPOT TEAM.'))
26 if 'componentLevel' not in data:
29 print(
'{0:^105}'.
format(
'Component Level Monitoring'))
31 print(
'{0:<18}{1:<10}{2:<20}{3:<20}{4:<20}{5:<20}'.
format(
'Step',
38 steps = [
'Initialize',
'FirstEvent',
'Execute',
'Finalize',
'Callback',
'preLoadProxy']
44 for entry
in sorted(data[
'componentLevel'][step],
45 key=
lambda x: data[
'componentLevel'][step][x][orderBy], reverse =
True):
46 print(
'{0:<18}{1:<10}{2:<20.2f}{3:<20}{4:<20}{5:<20}'.
format(step,
47 data[
'componentLevel'][step][entry][
'count'],
48 data[
'componentLevel'][step][entry][
'cpuTime'],
49 data[
'componentLevel'][step][entry][
'vmem'],
50 data[
'componentLevel'][step][entry][
'malloc'],
53 if (ncomps == maxComps):
61 if 'eventLevel' not in data:
66 print(
'{0:^15}{1:^15}{2:^15}{3:^15}{4:^15}{5:^15}{6:^15}'.
format(
'Event',
74 for entry
in sorted(data[
'eventLevel'], key=float):
75 print(
'{0:^15}{1:^15.2f}{2:^15.2f}{3:^15}{4:^15}{5:^15}{6:^15}'.
format(entry,
76 data[
'eventLevel'][entry][
'cpuTime']*0.001,
77 data[
'eventLevel'][entry][
'wallTime']*0.001,
78 data[
'eventLevel'][entry][
'vmem'],
79 data[
'eventLevel'][entry][
'rss'],
80 data[
'eventLevel'][entry][
'pss'],
81 data[
'eventLevel'][entry][
'swap']))
84 if 'summary' not in data:
86 if 'snapshotLevel' not in data[
'summary']:
91 print(
'{0:<14}{1:<13}{2:<13}{3:<13}{4:<13}{5:<13}{6:<13}{7:<13}'.
format(
'Step',
100 for entry
in [
'Configure',
'Initialize',
'FirstEvent',
'Execute',
'Finalize']:
101 print(
'{0:<14}{1:<13.2f}{2:<13.2f}{3:<13.2f}{4:<13}{5:<13}{6:<13}{7:<13}'.
format(entry,
102 data[
'summary'][
'snapshotLevel'][entry][
'dCPU']*0.001,
103 data[
'summary'][
'snapshotLevel'][entry][
'dWall']*0.001,
104 data[
'summary'][
'snapshotLevel'][entry][
'cpuUtil'],
105 data[
'summary'][
'snapshotLevel'][entry][
'dVmem'],
106 data[
'summary'][
'snapshotLevel'][entry][
'dRss'],
107 data[
'summary'][
'snapshotLevel'][entry][
'dPss'],
108 data[
'summary'][
'snapshotLevel'][entry][
'dSwap']))
110 print(
'{0:<40}{1:<}'.
format(
'Number of events processed:',
111 data[
'summary'][
'nEvents']))
112 nEvents =
float(data[
'summary'][
'nEvents'])
113 cpuExec =
float(data[
'summary'][
'snapshotLevel'][
'FirstEvent'][
'dCPU']) +
float(data[
'summary'][
'snapshotLevel'][
'Execute'][
'dCPU'])
114 wallExec =
float(data[
'summary'][
'snapshotLevel'][
'FirstEvent'][
'dWall']) +
float(data[
'summary'][
'snapshotLevel'][
'Execute'][
'dWall'])
115 print(
'{0:<40}{1:<.0f}'.
format(
'CPU usage per event [ms]:', cpuExec/nEvents))
116 print(
'{0:<40}{1:<.3f}'.
format(
'Events per second:', nEvents/wallExec*1000.))
117 print(
'{0:<40}{1:<}'.
format(
'CPU utilization efficiency [%]:', data[
'summary'][
'misc'][
'cpuUtilEff']))
120 float(data[
'summary'][
'peaks'][
'vmemPeak'])/1024./1024.))
122 float(data[
'summary'][
'peaks'][
'rssPeak'])/1024./1024))
124 float(data[
'summary'][
'peaks'][
'pssPeak'])/1024./1024.))
126 print(
'{0:<40}{1:<.2f} MB'.
format(
'Leak estimate per event Vmem:',
127 float(data[
'summary'][
'leakEstimates'][
'vmemLeak'])/1024.))
128 print(
'{0:<40}{1:<.2f} MB'.
format(
'Leak estimate per event Pss:',
129 float(data[
'summary'][
'leakEstimates'][
'pssLeak'])/1024.))
130 print(
' >> Estimated using the last {0} measurements from the Event Level Monitoring'.
format(data[
'summary'][
'leakEstimates'][
'nPoints']))
131 print(
' >> Events prior to the first 25 are omitted...')
138 print(
'{0:<40}{1:<}'.
format(
'CPU Model:',data[
'summary'][
'sysInfo'][
'cpuModel'].lstrip()))
139 print(
'{0:<40}{1:<}'.
format(
'Number of Available Cores:',data[
'summary'][
'sysInfo'][
'coreNum']))
140 print(
'{0:<40}{1:<.2f} GB'.
format(
'Total Memory:',
float(data[
'summary'][
'sysInfo'][
'totMem'])/1024./1024.))
146 print(
'{0:^105}'.
format(
'Environment Information'))
148 print(
'{0:<40}{1:<}'.
format(
'Malloc Library:',data[
'summary'][
'envInfo'][
'mallocLib']))
149 print(
'{0:<40}{1:<}'.
format(
'Math Library:',data[
'summary'][
'envInfo'][
'mathLib']))
158 if args.level
in [
'All',
'ComponentLevel']:
164 if args.level
in [
'All',
'EventLevel']:
168 if args.level
in [
'All',
'SummaryLevel']:
172 if args.level
in [
'All']:
179 if '__main__' in __name__:
182 parser = argparse.ArgumentParser(description =
'Script to print tables using PerfMonMTSvc JSON')
184 parser.add_argument(
'-i',
'--input', type = str, required =
True,
185 help =
'PerfMonMTSvc JSON file')
186 parser.add_argument(
'-l',
'--level', nargs =
'?', default =
'All',
187 choices = [
'All',
'SummaryLevel',
'EventLevel',
'ComponentLevel'],
188 help =
'Sets the level of detail in the printout')
189 parser.add_argument(
'-e',
'--exec-only', dest =
'exec_only', action =
'store_true',
190 help =
'Print only the execute step for the components')
191 parser.add_argument(
'-o',
'--order-by', dest =
'order_by', nargs =
'?', default =
'cpuTime',
192 choices = [
'cpuTime',
'vmem',
'malloc'],
193 help =
'Order components by a specific metric')
194 parser.add_argument(
'-m',
'--max-components', dest =
'max_comps', type = int, default = -1,
195 help =
'The maximum number of compoments to be printed '
198 args = parser.parse_args()
201 if tarfile.is_tarfile(args.input):
203 tar = tarfile.open(args.input)
205 for member
in tar.getmembers():
206 f = tar.extractfile(member)
215 with(
open(args.input))
as json_file:
216 data = json.load(json_file)