Changeset e9c5db2


Ignore:
Timestamp:
Apr 27, 2022, 4:59:41 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
0bd6a14, 1784e9e
Parents:
a6c10de
Message:

Minor fixes to benchmark processing scripts

Location:
benchmark
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • benchmark/plot.py

    ra6c10de re9c5db2  
    2222
    2323class Field:
    24         def __init__(self, unit, _min):
     24        def __init__(self, unit, _min, _log):
    2525                self.unit = unit
    2626                self.min  = _min
     27                self.log  = _log
    2728
    2829field_names = {
    29         "ns per ops"           : Field('ns'    , 0),
    30         "Number of processors" : Field(''      , 1),
    31         "Ops per procs"        : Field('Ops'   , 0),
    32         "Ops per threads"      : Field('Ops'   , 0),
    33         "ns per ops/procs"     : Field('ns'    , 0),
    34         "Number of threads"    : Field('thrd'  , 1),
    35         "Total Operations(ops)": Field('Ops'   , 0),
    36         "Ops/sec/procs"        : Field('Ops'   , 0),
    37         "Total blocks"         : Field('Blocks', 0),
    38         "Ops per second"       : Field('Ops'   , 0),
    39         "Cycle size (# thrds)" : Field('thrd'  , 1),
    40         "Duration (ms)"        : Field('ms'    , 0),
     30        "ns per ops"            : Field('ns'    , 0, False),
     31        "Number of processors"  : Field(''      , 1, False),
     32        "Ops per procs"         : Field('Ops'   , 0, False),
     33        "Ops per threads"       : Field('Ops'   , 0, False),
     34        "ns per ops/procs"      : Field('ns'    , 0, False),
     35        "Number of threads"     : Field('thrd'  , 1, False),
     36        "Total Operations(ops)" : Field('Ops'   , 0, False),
     37        "Ops/sec/procs"         : Field('Ops'   , 0, False),
     38        "Total blocks"          : Field('Blocks', 0, False),
     39        "Ops per second"        : Field('Ops'   , 0, False),
     40        "Cycle size (# thrds)"  : Field('thrd'  , 1, False),
     41        "Duration (ms)"         : Field('ms'    , 0, False),
     42        "Target QPS"            : Field('QPS'   , 0, False),
     43        "Actual QPS"            : Field('QPS'   , 0, False),
     44        "Median Read Latency"   : Field('us'    , 0, True),
     45        "Tail Read Latency"     : Field('us'    , 0, True),
     46        "Median Update Latency" : Field('us'    , 0, True),
     47        "Tail Update Latency"   : Field('us'    , 0, True),
    4148}
    4249
     
    4653        series = {} # scatter data for each individual data point
    4754        groups = {} # data points for x value
     55
     56        print("Preparing Data")
     57
    4858        for entry in in_data:
    4959                name = entry[0]
     
    6575                        groups[name][xval].append(yval)
    6676
     77        print("Preparing Lines")
     78
    6779        lines = {} # lines from groups with min, max, median, etc.
    6880        for name, data in groups.items():
     
    7890                        lines[name]['avg'].append(statistics.mean(ys))
    7991
     92        print("Making Plots")
     93
    8094        for name, data in series.items():
    8195                _col = next(colors)
     
    8599                plt.plot(lines[name]['x'], lines[name]['med'], '-', color=_col)
    86100
     101        print("Calculating Extremums")
     102
    87103        mx = max([max(s['x']) for s in series.values()])
    88104        my = max([max(s['y']) for s in series.values()])
    89105
     106        print("Finishing Plots")
     107
    90108        plt.ylabel(y)
    91         plt.xlim(field_names[x].min, mx + 0.25)
    92         plt.xticks(range(1, math.ceil(mx) + 1))
     109        # plt.xticks(range(1, math.ceil(mx) + 1))
    93110        plt.xlabel(x)
    94         plt.ylim(field_names[y].min, my*1.2)
    95111        plt.grid(b = True)
    96112        ax.xaxis.set_major_formatter( EngFormatter(unit=field_names[x].unit) )
     113        if field_names[x].log:
     114                ax.set_xscale('log')
     115        else:
     116                plt.xlim(field_names[x].min, mx + 0.25)
     117
    97118        ax.yaxis.set_major_formatter( EngFormatter(unit=field_names[y].unit) )
     119        if field_names[y].log:
     120                ax.set_yscale('log')
     121        else:
     122                plt.ylim(field_names[y].min, my*1.2)
     123
    98124        plt.legend(loc='upper left')
     125
     126        print("Results Ready")
    99127        if out:
    100128                plt.savefig(out)
     
    106134        # ================================================================================
    107135        # parse command line arguments
    108         parser = parser = argparse.ArgumentParser(description='Python Script to draw R.M.I.T. results')
    109         parser.add_argument('-f', '--file', nargs='?', type=argparse.FileType('r'), default=sys.stdin)
    110         parser.add_argument('-o', '--out', nargs='?', type=str, default=None)
    111         parser.add_argument('-y', nargs='?', type=str, default="")
     136        parser = argparse.ArgumentParser(description='Python Script to draw R.M.I.T. results')
     137        parser.add_argument('-f', '--file', nargs='?', type=argparse.FileType('r'), default=sys.stdin, help="Input file")
     138        parser.add_argument('-o', '--out', nargs='?', type=str, default=None, help="Output file")
     139        parser.add_argument('-y', nargs='?', type=str, default="", help="Which field to use as the Y axis")
     140        parser.add_argument('-x', nargs='?', type=str, default="", help="Which field to use as the X axis")
    112141
    113         try:
    114                 options =  parser.parse_args()
    115         except:
    116                 print('ERROR: invalid arguments', file=sys.stderr)
    117                 parser.print_help(sys.stderr)
    118                 sys.exit(1)
     142        options =  parser.parse_args()
    119143
    120144        # ================================================================================
     
    140164        if not options.out :
    141165                print(series)
    142                 print("fields")
    143                 for f in fields:
    144                         print("{}".format(f))
     166                print("fields: ", ' '.join(fields))
    145167
    146         if options.y and options.y in field_names.keys():
    147                 plot(data, "Number of processors", options.y, options.out)
    148         else:
    149                 if options.y:
    150                         print("Could not find key '{}', defaulting to 'ns per ops'".format(options.y))
    151                 plot(data, "Number of processors", "ns per ops", options.out)
     168        wantx = "Number of processors"
     169        wanty = "ns per ops"
     170
     171        if options.x:
     172                if options.x in field_names.keys():
     173                        wantx = options.x
     174                else:
     175                        print("Could not find X key '{}', defaulting to '{}'".format(options.x, wantx))
     176
     177        if options.y:
     178                if options.y in field_names.keys():
     179                        wanty = options.y
     180                else:
     181                        print("Could not find Y key '{}', defaulting to '{}'".format(options.y, wanty))
     182
     183
     184        plot(data, wantx, wanty, options.out)
  • benchmark/rmit.py

    ra6c10de re9c5db2  
    281281
    282282        if options.file != sys.stdout:
    283                 print("Done                                                                                ")
     283                print("Done");                                                                                ")
Note: See TracChangeset for help on using the changeset viewer.