Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/plot.py

    r8fca132 rc0458be3  
    1818import statistics
    1919import sys
    20 import time
    21 
    22 import matplotlib
     20
    2321import 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"
     22from matplotlib.ticker import EngFormatter
    3323
    3424class Field:
     
    4232field_names = {
    4333        "ns per ops"            : Field('ns'    , 0, False),
    44         "Number of processors"  : Field(''      , 1, "exact"),
     34        "Number of processors"  : Field(''      , 1, False),
    4535        "Ops per procs"         : Field('Ops'   , 0, False),
    4636        "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))" ),
    4838        "Number of threads"     : Field(''      , 1, False),
    4939        "Total Operations(ops)" : Field('Ops'   , 0, False),
     
    5545        "Target QPS"            : Field(''      , 0, False),
    5646        "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),
    5848        "Median Read Latency"   : Field('s'     , 0, True, _factor = 0.000001),
    5949        "Tail Read Latency"     : Field('s'     , 0, True, _factor = 0.000001),
     
    6151        "Median Update Latency" : Field('s'     , 0, True, _factor = 0.000001),
    6252        "Tail Update Latency"   : Field('s'     , 0, True, _factor = 0.000001),
    63         "Update Ratio"          : Field('%'   , 0, False),
     53        "Update Ratio"          : Field('\%'    , 0, False),
    6454        "Request Rate"          : Field('req/s' , 0, False),
    6555        "Data Rate"             : Field('b/s'   , 0, False, _factor = 1000 * 1000, _name = "Response Throughput"),
    66         "Errors"                : Field('%'   , 0, False),
    6756}
    6857
    6958def plot(in_data, x, y, options, prefix):
    7059        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
    7563
    7664        print("Preparing Data")
     
    7866        for entry in in_data:
    7967                name = entry[0]
    80                 if options.filter and not name.startswith(options.filter):
    81                         continue
    82 
    8368                if not name in series:
    8469                        series[name] = {'x':[], 'y':[]}
     
    117102        for name, data in sorted(series.items()):
    118103                _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)
    122106                plt.plot(lines[name]['x'], lines[name]['max'], '--', color=_col)
    123107                plt.plot(lines[name]['x'], lines[name]['med'], '-', color=_col)
     
    139123        elif field_names[x].log:
    140124                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)
    148125        else:
    149126                plt.xlim(field_names[x].min, mx + 0.25)
     
    161138
    162139        print("Results Ready")
    163         start = time.time()
    164140        if options.out:
    165141                plt.savefig(options.out, bbox_inches='tight')
    166142        else:
    167143                plt.show()
    168         end = time.time()
    169         print("Took {}".format(fmtDur(end - start)))
    170144
    171145
     
    181155        parser.add_argument('--logy', action='store_true', help="if set, makes the y-axis logscale")
    182156        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")
    184157
    185158        options =  parser.parse_args()
    186 
    187         # if not options.out:
    188         #       matplotlib.use('SVG')
    189159
    190160        # ================================================================================
     
    208178                        fields.add(label)
    209179
    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
    215181        prefix = os.path.commonprefix(list(series))
    216182
Note: See TracChangeset for help on using the changeset viewer.