Changeset 76f5e9f
- Timestamp:
- May 18, 2022, 4:07:47 PM (2 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
- Children:
- 31540f5
- Parents:
- 288927f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/plot.py
r288927f r76f5e9f 22 22 23 23 class Field: 24 def __init__(self, unit, _min, _log ):24 def __init__(self, unit, _min, _log, _name=None): 25 25 self.unit = unit 26 26 self.min = _min 27 27 self.log = _log 28 self.name = _name 28 29 29 30 field_names = { … … 32 33 "Ops per procs" : Field('Ops' , 0, False), 33 34 "Ops per threads" : Field('Ops' , 0, False), 34 "ns per ops/procs" : Field(' ns' , 0, False),35 "ns per ops/procs" : Field('' , 0, False, _name = "Latency (ns $/$ (Processor $\\times$ Operation))" ), 35 36 "Number of threads" : Field('' , 1, False), 36 37 "Total Operations(ops)" : Field('Ops' , 0, False), 37 38 "Ops/sec/procs" : Field('Ops' , 0, False), 38 39 "Total blocks" : Field('Blocks', 0, False), 39 "Ops per second" : Field(' Ops' , 0, False),40 "Ops per second" : Field('' , 0, False), 40 41 "Cycle size (# thrds)" : Field('thrd' , 1, False), 41 42 "Duration (ms)" : Field('ms' , 0, False), … … 51 52 } 52 53 53 def plot(in_data, x, y, o ut):54 def plot(in_data, x, y, options): 54 55 fig, ax = plt.subplots() 55 56 colors = itertools.cycle(['#0095e3','#006cb4','#69df00','#0aa000','#fb0300','#e30002','#fd8f00','#ff7f00','#8f00d6','#4b009a','#ffff00','#b13f00']) … … 109 110 print("Finishing Plots") 110 111 111 plt.ylabel( y)112 plt.ylabel(field_names[y].name if field_names[y].name else y) 112 113 # plt.xticks(range(1, math.ceil(mx) + 1)) 113 plt.xlabel( x)114 plt.xlabel(field_names[x].name if field_names[x].name else x) 114 115 plt.grid(b = True) 115 116 ax.xaxis.set_major_formatter( EngFormatter(unit=field_names[x].unit) ) 116 if field_names[x].log: 117 if options.logx: 118 ax.set_xscale('log') 119 elif field_names[x].log: 117 120 ax.set_xscale('log') 118 121 else: … … 120 123 121 124 ax.yaxis.set_major_formatter( EngFormatter(unit=field_names[y].unit) ) 122 if field_names[y].log: 125 if options.logy: 126 ax.set_yscale('log') 127 elif field_names[y].log: 123 128 ax.set_yscale('log') 124 129 else: 125 plt.ylim(field_names[y].min, my*1.2)130 plt.ylim(field_names[y].min, options.MaxY if options.MaxY else my*1.2) 126 131 127 132 plt.legend(loc='upper left') 128 133 129 134 print("Results Ready") 130 if o ut:131 plt.savefig(o ut)135 if options.out: 136 plt.savefig(options.out, bbox_inches='tight') 132 137 else: 133 138 plt.show() … … 142 147 parser.add_argument('-y', nargs='?', type=str, default="", help="Which field to use as the Y axis") 143 148 parser.add_argument('-x', nargs='?', type=str, default="", help="Which field to use as the X axis") 149 parser.add_argument('--logx', action='store_true', help="if set, makes the x-axis logscale") 150 parser.add_argument('--logy', action='store_true', help="if set, makes the y-axis logscale") 151 parser.add_argument('--MaxY', nargs='?', type=int, help="maximum value of the y-axis") 144 152 145 153 options = parser.parse_args() … … 185 193 186 194 187 plot(data, wantx, wanty, options .out)195 plot(data, wantx, wanty, options)
Note: See TracChangeset
for help on using the changeset viewer.