Changes in benchmark/plot.py [c0458be3:8fca132]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/plot.py
rc0458be3 r8fca132 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 $/$ (Processor $\\times$ Operation))" ),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), … … 45 55 "Target QPS" : Field('' , 0, False), 46 56 "Actual QPS" : Field('' , 0, False), 47 "Average Read Latency" : Field('s' , 0, True, _factor = 0.000001),57 "Average Read Latency" : Field('s' , 0, False, _factor = 0.000001), 48 58 "Median Read Latency" : Field('s' , 0, True, _factor = 0.000001), 49 59 "Tail Read Latency" : Field('s' , 0, True, _factor = 0.000001), … … 51 61 "Median Update Latency" : Field('s' , 0, True, _factor = 0.000001), 52 62 "Tail Update Latency" : Field('s' , 0, True, _factor = 0.000001), 53 "Update Ratio" : Field(' \%', 0, False),63 "Update Ratio" : Field('%' , 0, False), 54 64 "Request Rate" : Field('req/s' , 0, False), 55 65 "Data Rate" : Field('b/s' , 0, False, _factor = 1000 * 1000, _name = "Response Throughput"), 66 "Errors" : Field('%' , 0, False), 56 67 } 57 68 58 69 def plot(in_data, x, y, options, prefix): 59 70 fig, ax = plt.subplots() 60 colors = itertools.cycle(['#006cb4','#0aa000','#ff6600','#8510a1','#0095e3','#fd8f00','#e30002','#8f00d6','#4b009a','#ffff00','#69df00','#fb0300','#b13f00']) 61 series = {} # scatter data for each individual data point 62 groups = {} # data points for x value 71 colors = itertools.cycle(['#006cb4','#0aa000','#ff6600','#8510a1','#0095e3','#fd8f00','#e30002','#8f00d6','#4b009a','#ffff00','#69df00','#fb0300','#b13f00']) 72 markers = itertools.cycle(['x', '+', '1', '2', '3', '4']) 73 series = {} # scatter data for each individual data point 74 groups = {} # data points for x value 63 75 64 76 print("Preparing Data") … … 66 78 for entry in in_data: 67 79 name = entry[0] 80 if options.filter and not name.startswith(options.filter): 81 continue 82 68 83 if not name in series: 69 84 series[name] = {'x':[], 'y':[]} … … 102 117 for name, data in sorted(series.items()): 103 118 _col = next(colors) 104 plt.scatter(data['x'], data['y'], color=_col, label=name[len(prefix):], marker='x') 105 plt.plot(lines[name]['x'], lines[name]['min'], '--', color=_col) 119 _mrk = next(markers) 120 plt.scatter(data['x'], data['y'], color=_col, label=name[len(prefix):], marker=_mrk) 121 plt.plot(lines[name]['x'], lines[name]['min'], ':', color=_col) 106 122 plt.plot(lines[name]['x'], lines[name]['max'], '--', color=_col) 107 123 plt.plot(lines[name]['x'], lines[name]['med'], '-', color=_col) … … 123 139 elif field_names[x].log: 124 140 ax.set_xscale('log') 141 if field_names[x].log == "exact": 142 xvals = set() 143 for s in series.values(): 144 xvals |= set(s['x']) 145 ax.set_xticks(sorted(xvals)) 146 ax.get_xaxis().set_major_formatter(ScalarFormatter()) 147 plt.xticks(rotation = 45) 125 148 else: 126 149 plt.xlim(field_names[x].min, mx + 0.25) … … 138 161 139 162 print("Results Ready") 163 start = time.time() 140 164 if options.out: 141 165 plt.savefig(options.out, bbox_inches='tight') 142 166 else: 143 167 plt.show() 168 end = time.time() 169 print("Took {}".format(fmtDur(end - start))) 144 170 145 171 … … 155 181 parser.add_argument('--logy', action='store_true', help="if set, makes the y-axis logscale") 156 182 parser.add_argument('--MaxY', nargs='?', type=int, help="maximum value of the y-axis") 183 parser.add_argument('--filter', nargs='?', type=str, default="", help="if not empty, only print series that start with specified filter") 157 184 158 185 options = parser.parse_args() 186 187 # if not options.out: 188 # matplotlib.use('SVG') 159 189 160 190 # ================================================================================ … … 178 208 fields.add(label) 179 209 180 # find the common prefix on series for removal 210 # filter out the series if needed 211 if options.filter: 212 series = set(filter(lambda elem: elem.startswith(options.filter), series)) 213 214 # find the common prefix on series for removal (only if no filter) 181 215 prefix = os.path.commonprefix(list(series)) 182 216
Note:
See TracChangeset
for help on using the changeset viewer.