Changes in benchmark/plot.py [8fca132:76f5e9f]
- File:
-
- 1 edited
-
benchmark/plot.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
benchmark/plot.py
r8fca132 r76f5e9f 14 14 import math 15 15 import numpy 16 import os17 16 import re 18 17 import statistics 19 18 import sys 20 import time21 19 22 import matplotlib23 20 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" 21 from matplotlib.ticker import EngFormatter 33 22 34 23 class Field: 35 def __init__(self, unit, _min, _log, _name=None , _factor=1.0):24 def __init__(self, unit, _min, _log, _name=None): 36 25 self.unit = unit 37 26 self.min = _min 38 27 self.log = _log 39 28 self.name = _name 40 self.factor = _factor41 29 42 30 field_names = { 43 31 "ns per ops" : Field('ns' , 0, False), 44 "Number of processors" : Field('' , 1, "exact"),32 "Number of processors" : Field('' , 1, False), 45 33 "Ops per procs" : Field('Ops' , 0, False), 46 34 "Ops per threads" : Field('Ops' , 0, False), 47 "ns per ops/procs" : Field('' , 0, False, _name = "ns $\\times$ (Processor $/$ Total Ops)" ),35 "ns per ops/procs" : Field('' , 0, False, _name = "Latency (ns $/$ (Processor $\\times$ Operation))" ), 48 36 "Number of threads" : Field('' , 1, False), 49 37 "Total Operations(ops)" : Field('Ops' , 0, False), 50 38 "Ops/sec/procs" : Field('Ops' , 0, False), 51 39 "Total blocks" : Field('Blocks', 0, False), 52 "Ops per second" : Field('' , 0, False),40 "Ops per second" : Field('' , 0, False), 53 41 "Cycle size (# thrds)" : Field('thrd' , 1, False), 54 42 "Duration (ms)" : Field('ms' , 0, False), 55 43 "Target QPS" : Field('' , 0, False), 56 44 "Actual QPS" : Field('' , 0, False), 57 "Average Read Latency" : Field('s' , 0, False, _factor = 0.000001), 58 "Median Read Latency" : Field('s' , 0, True, _factor = 0.000001), 59 "Tail Read Latency" : Field('s' , 0, True, _factor = 0.000001), 60 "Average Update Latency": Field('s' , 0, True, _factor = 0.000001), 61 "Median Update Latency" : Field('s' , 0, True, _factor = 0.000001), 62 "Tail Update Latency" : Field('s' , 0, True, _factor = 0.000001), 63 "Update Ratio" : Field('%' , 0, False), 64 "Request Rate" : Field('req/s' , 0, False), 65 "Data Rate" : Field('b/s' , 0, False, _factor = 1000 * 1000, _name = "Response Throughput"), 66 "Errors" : Field('%' , 0, False), 45 "Average Read Latency" : Field('us' , 0, True), 46 "Median Read Latency" : Field('us' , 0, True), 47 "Tail Read Latency" : Field('us' , 0, True), 48 "Average Update Latency": Field('us' , 0, True), 49 "Median Update Latency" : Field('us' , 0, True), 50 "Tail Update Latency" : Field('us' , 0, True), 51 "Update Ratio" : Field('\%' , 0, False), 67 52 } 68 53 69 def plot(in_data, x, y, options , prefix):54 def plot(in_data, x, y, options): 70 55 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 56 colors = itertools.cycle(['#0095e3','#006cb4','#69df00','#0aa000','#fb0300','#e30002','#fd8f00','#ff7f00','#8f00d6','#4b009a','#ffff00','#b13f00']) 57 series = {} # scatter data for each individual data point 58 groups = {} # data points for x value 75 59 76 60 print("Preparing Data") … … 78 62 for entry in in_data: 79 63 name = entry[0] 80 if options.filter and not name.startswith(options.filter):81 continue82 83 64 if not name in series: 84 65 series[name] = {'x':[], 'y':[]} … … 89 70 if x in entry[2] and y in entry[2]: 90 71 xval = entry[2][x] 91 yval = entry[2][y] * field_names[y].factor72 yval = entry[2][y] 92 73 series[name]['x'].append(xval) 93 74 series[name]['y'].append(yval) … … 117 98 for name, data in sorted(series.items()): 118 99 _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) 100 plt.scatter(data['x'], data['y'], color=_col, label=name, marker='x') 101 plt.plot(lines[name]['x'], lines[name]['min'], '--', color=_col) 122 102 plt.plot(lines[name]['x'], lines[name]['max'], '--', color=_col) 123 103 plt.plot(lines[name]['x'], lines[name]['med'], '-', color=_col) … … 139 119 elif field_names[x].log: 140 120 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 121 else: 149 122 plt.xlim(field_names[x].min, mx + 0.25) 150 123 124 ax.yaxis.set_major_formatter( EngFormatter(unit=field_names[y].unit) ) 151 125 if options.logy: 152 126 ax.set_yscale('log') … … 156 130 plt.ylim(field_names[y].min, options.MaxY if options.MaxY else my*1.2) 157 131 158 ax.yaxis.set_major_formatter( EngFormatter(unit=field_names[y].unit) )159 160 132 plt.legend(loc='upper left') 161 133 162 134 print("Results Ready") 163 start = time.time()164 135 if options.out: 165 136 plt.savefig(options.out, bbox_inches='tight') 166 137 else: 167 138 plt.show() 168 end = time.time()169 print("Took {}".format(fmtDur(end - start)))170 139 171 140 … … 181 150 parser.add_argument('--logy', action='store_true', help="if set, makes the y-axis logscale") 182 151 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 152 185 153 options = parser.parse_args() 186 187 # if not options.out:188 # matplotlib.use('SVG')189 154 190 155 # ================================================================================ … … 208 173 fields.add(label) 209 174 210 # filter out the series if needed211 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)215 prefix = os.path.commonprefix(list(series))216 217 175 if not options.out : 218 176 print(series) … … 235 193 236 194 237 plot(data, wantx, wanty, options , prefix)195 plot(data, wantx, wanty, options)
Note:
See TracChangeset
for help on using the changeset viewer.