Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/plot.py

    rc0458be3 r8fca132  
    1818import statistics
    1919import sys
    20 
     20import time
     21
     22import matplotlib
    2123import matplotlib.pyplot as plt
    22 from matplotlib.ticker import EngFormatter
     24from matplotlib.ticker import EngFormatter, ScalarFormatter
     25
     26def 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"
    2333
    2434class Field:
     
    3242field_names = {
    3343        "ns per ops"            : Field('ns'    , 0, False),
    34         "Number of processors"  : Field(''      , 1, False),
     44        "Number of processors"  : Field(''      , 1, "exact"),
    3545        "Ops per procs"         : Field('Ops'   , 0, False),
    3646        "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)" ),
    3848        "Number of threads"     : Field(''      , 1, False),
    3949        "Total Operations(ops)" : Field('Ops'   , 0, False),
     
    4555        "Target QPS"            : Field(''      , 0, False),
    4656        "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),
    4858        "Median Read Latency"   : Field('s'     , 0, True, _factor = 0.000001),
    4959        "Tail Read Latency"     : Field('s'     , 0, True, _factor = 0.000001),
     
    5161        "Median Update Latency" : Field('s'     , 0, True, _factor = 0.000001),
    5262        "Tail Update Latency"   : Field('s'     , 0, True, _factor = 0.000001),
    53         "Update Ratio"          : Field('\%'    , 0, False),
     63        "Update Ratio"          : Field('%'   , 0, False),
    5464        "Request Rate"          : Field('req/s' , 0, False),
    5565        "Data Rate"             : Field('b/s'   , 0, False, _factor = 1000 * 1000, _name = "Response Throughput"),
     66        "Errors"                : Field('%'   , 0, False),
    5667}
    5768
    5869def plot(in_data, x, y, options, prefix):
    5970        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
    6375
    6476        print("Preparing Data")
     
    6678        for entry in in_data:
    6779                name = entry[0]
     80                if options.filter and not name.startswith(options.filter):
     81                        continue
     82
    6883                if not name in series:
    6984                        series[name] = {'x':[], 'y':[]}
     
    102117        for name, data in sorted(series.items()):
    103118                _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)
    106122                plt.plot(lines[name]['x'], lines[name]['max'], '--', color=_col)
    107123                plt.plot(lines[name]['x'], lines[name]['med'], '-', color=_col)
     
    123139        elif field_names[x].log:
    124140                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)
    125148        else:
    126149                plt.xlim(field_names[x].min, mx + 0.25)
     
    138161
    139162        print("Results Ready")
     163        start = time.time()
    140164        if options.out:
    141165                plt.savefig(options.out, bbox_inches='tight')
    142166        else:
    143167                plt.show()
     168        end = time.time()
     169        print("Took {}".format(fmtDur(end - start)))
    144170
    145171
     
    155181        parser.add_argument('--logy', action='store_true', help="if set, makes the y-axis logscale")
    156182        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")
    157184
    158185        options =  parser.parse_args()
     186
     187        # if not options.out:
     188        #       matplotlib.use('SVG')
    159189
    160190        # ================================================================================
     
    178208                        fields.add(label)
    179209
    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)
    181215        prefix = os.path.commonprefix(list(series))
    182216
Note: See TracChangeset for help on using the changeset viewer.