- Timestamp:
- Aug 14, 2022, 9:36:33 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation
- Children:
- 8bee858
- Parents:
- 0e34a14
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/plot.py
r0e34a14 r41a6a78 18 18 import statistics 19 19 import sys 20 20 import time 21 22 import matplotlib 21 23 import matplotlib.pyplot as plt 22 from matplotlib.ticker import EngFormatter 24 from matplotlib.ticker import EngFormatter, ScalarFormatter 25 26 def fmtDur( duration ): 27 if duration : 28 hours, rem = divmod(duration, 3600) 29 minutes, rem = divmod(rem, 60) 30 seconds, millis = divmod(rem, 1) 31 return "%2d:%02d.%03d" % (minutes, seconds, millis * 1000) 32 return " n/a" 23 33 24 34 class Field: … … 32 42 field_names = { 33 43 "ns per ops" : Field('ns' , 0, False), 34 "Number of processors" : Field('' , 1, False),44 "Number of processors" : Field('' , 1, "exact"), 35 45 "Ops per procs" : Field('Ops' , 0, False), 36 46 "Ops per threads" : Field('Ops' , 0, False), 37 "ns per ops/procs" : Field('' , 0, False, _name = " Latency ((ns $/$ Operation) $\\times$ Processor)" ),47 "ns per ops/procs" : Field('' , 0, False, _name = "ns $\\times$ (Processor $/$ Total Ops)" ), 38 48 "Number of threads" : Field('' , 1, False), 39 49 "Total Operations(ops)" : Field('Ops' , 0, False), … … 67 77 for entry in in_data: 68 78 name = entry[0] 79 if options.filter and not name.startswith(options.filter): 80 continue 81 69 82 if not name in series: 70 83 series[name] = {'x':[], 'y':[]} … … 124 137 elif field_names[x].log: 125 138 ax.set_xscale('log') 139 if field_names[x].log == "exact": 140 xvals = set() 141 for s in series.values(): 142 xvals |= set(s['x']) 143 ax.set_xticks(sorted(xvals)) 144 ax.get_xaxis().set_major_formatter(ScalarFormatter()) 145 plt.xticks(rotation = 45) 126 146 else: 127 147 plt.xlim(field_names[x].min, mx + 0.25) … … 139 159 140 160 print("Results Ready") 161 start = time.time() 141 162 if options.out: 142 163 plt.savefig(options.out, bbox_inches='tight') 143 164 else: 144 165 plt.show() 166 end = time.time() 167 print("Took {}".format(fmtDur(end - start))) 145 168 146 169 … … 156 179 parser.add_argument('--logy', action='store_true', help="if set, makes the y-axis logscale") 157 180 parser.add_argument('--MaxY', nargs='?', type=int, help="maximum value of the y-axis") 181 parser.add_argument('--filter', nargs='?', type=str, default="", help="if not empty, only print series that start with specified filter") 158 182 159 183 options = parser.parse_args() 184 185 # if not options.out: 186 # matplotlib.use('SVG') 160 187 161 188 # ================================================================================ … … 179 206 fields.add(label) 180 207 181 # find the common prefix on series for removal 208 # filter out the series if needed 209 if options.filter: 210 series = set(filter(lambda elem: elem.startswith(options.filter), series)) 211 212 # find the common prefix on series for removal (only if no filter) 182 213 prefix = os.path.commonprefix(list(series)) 183 214
Note: See TracChangeset
for help on using the changeset viewer.