Changes in benchmark/plot.py [8fca132:c0458be3]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
benchmark/plot.py
r8fca132 rc0458be3 18 18 import statistics 19 19 import sys 20 import time 21 22 import matplotlib 20 23 21 import matplotlib.pyplot as plt 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" 22 from matplotlib.ticker import EngFormatter 33 23 34 24 class Field: … … 42 32 field_names = { 43 33 "ns per ops" : Field('ns' , 0, False), 44 "Number of processors" : Field('' , 1, "exact"),34 "Number of processors" : Field('' , 1, False), 45 35 "Ops per procs" : Field('Ops' , 0, False), 46 36 "Ops per threads" : Field('Ops' , 0, False), 47 "ns per ops/procs" : Field('' , 0, False, _name = " ns $\\times$ (Processor $/$ Total Ops)" ),37 "ns per ops/procs" : Field('' , 0, False, _name = "Latency (ns $/$ (Processor $\\times$ Operation))" ), 48 38 "Number of threads" : Field('' , 1, False), 49 39 "Total Operations(ops)" : Field('Ops' , 0, False), … … 55 45 "Target QPS" : Field('' , 0, False), 56 46 "Actual QPS" : Field('' , 0, False), 57 "Average Read Latency" : Field('s' , 0, False, _factor = 0.000001),47 "Average Read Latency" : Field('s' , 0, True, _factor = 0.000001), 58 48 "Median Read Latency" : Field('s' , 0, True, _factor = 0.000001), 59 49 "Tail Read Latency" : Field('s' , 0, True, _factor = 0.000001), … … 61 51 "Median Update Latency" : Field('s' , 0, True, _factor = 0.000001), 62 52 "Tail Update Latency" : Field('s' , 0, True, _factor = 0.000001), 63 "Update Ratio" : Field(' %', 0, False),53 "Update Ratio" : Field('\%' , 0, False), 64 54 "Request Rate" : Field('req/s' , 0, False), 65 55 "Data Rate" : Field('b/s' , 0, False, _factor = 1000 * 1000, _name = "Response Throughput"), 66 "Errors" : Field('%' , 0, False),67 56 } 68 57 69 58 def plot(in_data, x, y, options, prefix): 70 59 fig, ax = plt.subplots() 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 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 75 63 76 64 print("Preparing Data") … … 78 66 for entry in in_data: 79 67 name = entry[0] 80 if options.filter and not name.startswith(options.filter):81 continue82 83 68 if not name in series: 84 69 series[name] = {'x':[], 'y':[]} … … 117 102 for name, data in sorted(series.items()): 118 103 _col = next(colors) 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) 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) 122 106 plt.plot(lines[name]['x'], lines[name]['max'], '--', color=_col) 123 107 plt.plot(lines[name]['x'], lines[name]['med'], '-', color=_col) … … 139 123 elif field_names[x].log: 140 124 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)148 125 else: 149 126 plt.xlim(field_names[x].min, mx + 0.25) … … 161 138 162 139 print("Results Ready") 163 start = time.time()164 140 if options.out: 165 141 plt.savefig(options.out, bbox_inches='tight') 166 142 else: 167 143 plt.show() 168 end = time.time()169 print("Took {}".format(fmtDur(end - start)))170 144 171 145 … … 181 155 parser.add_argument('--logy', action='store_true', help="if set, makes the y-axis logscale") 182 156 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")184 157 185 158 options = parser.parse_args() 186 187 # if not options.out:188 # matplotlib.use('SVG')189 159 190 160 # ================================================================================ … … 208 178 fields.add(label) 209 179 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) 180 # find the common prefix on series for removal 215 181 prefix = os.path.commonprefix(list(series)) 216 182
Note:
See TracChangeset
for help on using the changeset viewer.