Changeset e5d9274 for benchmark/plot.py


Ignore:
Timestamp:
Jun 2, 2022, 3:11:21 PM (23 months ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
ced5e2a
Parents:
015925a (diff), fc134a48 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/plot.py

    r015925a re5d9274  
    2222
    2323class Field:
    24         def __init__(self, unit, _min, _log):
     24        def __init__(self, unit, _min, _log, _name=None):
    2525                self.unit = unit
    2626                self.min  = _min
    2727                self.log  = _log
     28                self.name = _name
    2829
    2930field_names = {
     
    3233        "Ops per procs"         : Field('Ops'   , 0, False),
    3334        "Ops per threads"       : Field('Ops'   , 0, False),
    34         "ns per ops/procs"      : Field('ns'    , 0, False),
     35        "ns per ops/procs"      : Field(''    , 0, False, _name = "Latency (ns $/$ (Processor $\\times$ Operation))" ),
    3536        "Number of threads"     : Field(''      , 1, False),
    3637        "Total Operations(ops)" : Field('Ops'   , 0, False),
    3738        "Ops/sec/procs"         : Field('Ops'   , 0, False),
    3839        "Total blocks"          : Field('Blocks', 0, False),
    39         "Ops per second"        : Field('Ops'   , 0, False),
     40        "Ops per second"        : Field(''   , 0, False),
    4041        "Cycle size (# thrds)"  : Field('thrd'  , 1, False),
    4142        "Duration (ms)"         : Field('ms'    , 0, False),
     
    5152}
    5253
    53 def plot(in_data, x, y, out):
     54def plot(in_data, x, y, options):
    5455        fig, ax = plt.subplots()
    5556        colors = itertools.cycle(['#0095e3','#006cb4','#69df00','#0aa000','#fb0300','#e30002','#fd8f00','#ff7f00','#8f00d6','#4b009a','#ffff00','#b13f00'])
     
    109110        print("Finishing Plots")
    110111
    111         plt.ylabel(y)
     112        plt.ylabel(field_names[y].name if field_names[y].name else y)
    112113        # plt.xticks(range(1, math.ceil(mx) + 1))
    113         plt.xlabel(x)
     114        plt.xlabel(field_names[x].name if field_names[x].name else x)
    114115        plt.grid(b = True)
    115116        ax.xaxis.set_major_formatter( EngFormatter(unit=field_names[x].unit) )
    116         if field_names[x].log:
     117        if options.logx:
     118                ax.set_xscale('log')
     119        elif field_names[x].log:
    117120                ax.set_xscale('log')
    118121        else:
     
    120123
    121124        ax.yaxis.set_major_formatter( EngFormatter(unit=field_names[y].unit) )
    122         if field_names[y].log:
     125        if options.logy:
     126                ax.set_yscale('log')
     127        elif field_names[y].log:
    123128                ax.set_yscale('log')
    124129        else:
    125                 plt.ylim(field_names[y].min, my*1.2)
     130                plt.ylim(field_names[y].min, options.MaxY if options.MaxY else my*1.2)
    126131
    127132        plt.legend(loc='upper left')
    128133
    129134        print("Results Ready")
    130         if out:
    131                 plt.savefig(out)
     135        if options.out:
     136                plt.savefig(options.out, bbox_inches='tight')
    132137        else:
    133138                plt.show()
     
    142147        parser.add_argument('-y', nargs='?', type=str, default="", help="Which field to use as the Y axis")
    143148        parser.add_argument('-x', nargs='?', type=str, default="", help="Which field to use as the X axis")
     149        parser.add_argument('--logx', action='store_true', help="if set, makes the x-axis logscale")
     150        parser.add_argument('--logy', action='store_true', help="if set, makes the y-axis logscale")
     151        parser.add_argument('--MaxY', nargs='?', type=int, help="maximum value of the y-axis")
    144152
    145153        options =  parser.parse_args()
     
    185193
    186194
    187         plot(data, wantx, wanty, options.out)
     195        plot(data, wantx, wanty, options)
Note: See TracChangeset for help on using the changeset viewer.