Changeset 44706d1


Ignore:
Timestamp:
Nov 24, 2020, 11:56:58 AM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
5c028ac
Parents:
0bb691b1
Message:

Improved colors and units of plotter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/plot.py

    r0bb691b1 r44706d1  
    2020from matplotlib.ticker import EngFormatter
    2121
    22 def funit(name):
    23         match = re.search("Number of (.*)", name)
    24         if match:
    25                 return match.group(1).strip()
     22class Field:
     23        def __init__(self, unit, _min):
     24                self.unit = unit
     25                self.min  = _min
    2626
    27         match = re.search("\((.*)\)", name)
    28         if match:
    29                 return match.group(1).strip()
    30 
    31         match = re.search("(.*) per .*", name)
    32         if match:
    33                 return match.group(1).strip()
    34 
    35         match = re.search("(.*)\/.*", name)
    36         if match:
    37                 return match.group(1).strip()
    38 
    39         return "Unkown"
     27field_names = {
     28        "ns per ops"           : Field('ns'    , 0),
     29        "Number of processors" : Field(''      , 1),
     30        "Ops per procs"        : Field('Ops'   , 0),
     31        "Ops per threads"      : Field('Ops'   , 0),
     32        "ns per ops/procs"     : Field('ns'    , 0),
     33        "Number of threads"    : Field('thrd'  , 1),
     34        "Total Operations(ops)": Field('Ops'   , 0),
     35        "Ops/sec/procs"        : Field('Ops'   , 0),
     36        "Total blocks"         : Field('Blocks', 0),
     37        "Ops per second"       : Field('Ops'   , 0),
     38        "Cycle size (# thrds)" : Field('thrd'  , 1),
     39        "Duration (ms)"        : Field('ms'    , 0),
     40}
    4041
    4142def plot(data, x, y):
    4243        fig, ax = plt.subplots()
    43         colors = itertools.cycle(["r", "b", "g"])
     44        colors = itertools.cycle(['#0095e3','#006cb4','#69df00','#0aa000','#fb0300','#e30002','#fd8f00','#ff7f00','#8f00d6','#4b009a','#ffff00','#b13f00'])
    4445        series = {}
    4546        for entry in data:
     
    5859
    5960        plt.ylabel(y)
    60         plt.xlim(0.75, mx + 0.25)
     61        plt.xlim(field_names[x].min, mx + 0.25)
    6162        plt.xticks(range(1, math.ceil(mx) + 1))
    6263        plt.xlabel(x)
    63         plt.ylim(0, my*1.2)
     64        plt.ylim(field_names[y].min, my*1.2)
    6465        plt.grid(b = True)
    65         formatter0 = EngFormatter(unit='Ops/s')
    66         ax.yaxis.set_major_formatter(formatter0)
    67         plt.legend()
     66        ax.xaxis.set_major_formatter( EngFormatter(unit=field_names[x].unit) )
     67        ax.yaxis.set_major_formatter( EngFormatter(unit=field_names[y].unit) )
     68        plt.legend(loc='upper left')
    6869        plt.show()
    6970
     
    105106        print("fields")
    106107        for f in fields:
    107                 print("{} ({})".format(f, funit(f)))
     108                print("{}".format(f))
    108109
    109         plot(data, "Number of processors", "Ops per second")
     110        plot(data, "Number of processors", "ns per ops")
Note: See TracChangeset for help on using the changeset viewer.