Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:45

0001 #!/usr/bin/env python3
0002 import sys
0003 import xml.etree.ElementTree
0004 import json
0005 import os
0006 
0007 from argparse import ArgumentParser
0008 parser = ArgumentParser()
0009 parser.add_argument("input", metavar="input.xml", type=str)
0010 parser.add_argument("output", metavar="output.json", type=str)
0011 options = parser.parse_args()
0012 
0013 timing={}
0014 
0015 try:
0016     tree = xml.etree.ElementTree.parse(options.input)
0017     timing['NumberEvents']=int(tree.find("./PerformanceReport/PerformanceSummary[@Metric='ProcessingSummary']/Metric[@Name='NumberEvents']").get('Value'))
0018     for x in tree.findall("./PerformanceReport/PerformanceSummary[@Metric='Timing']/Metric"):
0019         timing['Timing/'+x.get('Name')]=float(x.get('Value'))
0020     for x in tree.findall("./PerformanceReport/PerformanceSummary[@Metric='ApplicationMemory']/Metric"):
0021         timing['ApplicationMemory/'+x.get('Name')]=float(x.get('Value'))
0022 except Exception as e:
0023     print("Could not parse job report %s, content is:" % options.input)
0024     os.system("cat %s" % options.input)
0025     raise e
0026 
0027 
0028 with open(options.output,'w') as f:
0029     json.dump(timing,f)