File indexing completed on 2024-04-06 12:23:45
0001
0002 import json
0003
0004 from argparse import ArgumentParser, ArgumentDefaultsHelpFormatter
0005 parser = ArgumentParser(formatter_class=ArgumentDefaultsHelpFormatter)
0006 parser.add_argument("-f", "--format", dest="fmt", default="txt", help="output format")
0007 parser.add_argument("-H", "--header", dest="header", action="store_true", default=False, help="print headers")
0008 parser.add_argument("--base", dest="base", default="{}.json,{}_timing_report.json", help="comma-separated base name for size and timing files")
0009 parser.add_argument("--ref", dest="ref", default="ref/", help="path to the reference files")
0010 parser.add_argument("job", type=str, nargs='+')
0011 options = parser.parse_args()
0012
0013 headers = [ 'Sample' , 'kb/ev' , 'ref kb/ev' , 'diff kb/ev' , 'ev/s/thd' , 'ref ev/s/thd' , 'diff rate' , 'mem/thd' , 'ref mem/thd' ]
0014 start, sep, end = "", "\t", ""
0015 if options.fmt == "md":
0016 start, sep, end = "| ", " | ", " |"
0017
0018 def prow(x):
0019 print(start + sep.join(x) + end)
0020
0021 first = True
0022
0023 size_pattern,timing_pattern = options.base.split(',')
0024 for job in options.job:
0025
0026 label = job
0027 size_json=size_pattern.format(job)
0028 size_ref_json=options.ref+'/'+size_json
0029 timing_json=timing_pattern.format(job)
0030 timing_ref_json=options.ref+'/'+timing_json
0031
0032 try:
0033
0034 jnew = json.load(open(size_json,'r'))
0035 jref = json.load(open(size_ref_json,'r'))
0036 size_new = jnew["trees"]["Events"]['allsize']/jnew["trees"]["Events"]['entries']
0037 size_ref = jref["trees"]["Events"]['allsize']/jref["trees"]["Events"]['entries']
0038
0039 jnew_t = json.load(open(timing_json,'r'))
0040 jref_t = json.load(open(timing_ref_json,'r'))
0041 rate_new = jnew_t["Timing/EventThroughput"]/jnew_t["Timing/NumberOfThreads"]
0042 rate_ref = jref_t["Timing/EventThroughput"]/jref_t["Timing/NumberOfThreads"]
0043 try:
0044 rmem_new = jnew_t["ApplicationMemory/PeakValueRss"]/jnew_t["Timing/NumberOfThreads"]
0045 rmem_ref = jref_t["ApplicationMemory/PeakValueRss"]/jref_t["Timing/NumberOfThreads"]
0046 except KeyError:
0047 rmem_new = 0
0048 rmem_ref = 0
0049
0050 if first and options.header:
0051 prow(headers)
0052 if options.fmt == "md": prow("---" for x in headers)
0053 first = False
0054
0055 prow([ label, '%.3f' % size_new, '%.3f' % size_ref, '%.3f ( %+.1f%% )' % (size_new - size_ref, (size_new-size_ref)/size_ref * 100 ),
0056 '%.2f'%rate_new, '%.2f'%rate_ref, '%+.1f%%'%((rate_new-rate_ref)/rate_ref*100), '%.3f'%(rmem_new/1000), '%.3f'%(rmem_ref/1000) ])
0057
0058 except IOError:
0059
0060 pass