Changeset 41a6a78


Ignore:
Timestamp:
Aug 14, 2022, 9:36:33 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, ast-experimental, master, pthread-emulation
Children:
8bee858
Parents:
0e34a14
Message:

It was brought to my attention that I forgot to commit this file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/plot.py

    r0e34a14 r41a6a78  
    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 $/$ Operation) $\\times$ Processor)" ),
     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),
     
    6777        for entry in in_data:
    6878                name = entry[0]
     79                if options.filter and not name.startswith(options.filter):
     80                        continue
     81
    6982                if not name in series:
    7083                        series[name] = {'x':[], 'y':[]}
     
    124137        elif field_names[x].log:
    125138                ax.set_xscale('log')
     139                if field_names[x].log == "exact":
     140                        xvals = set()
     141                        for s in series.values():
     142                                xvals |= set(s['x'])
     143                        ax.set_xticks(sorted(xvals))
     144                        ax.get_xaxis().set_major_formatter(ScalarFormatter())
     145                        plt.xticks(rotation = 45)
    126146        else:
    127147                plt.xlim(field_names[x].min, mx + 0.25)
     
    139159
    140160        print("Results Ready")
     161        start = time.time()
    141162        if options.out:
    142163                plt.savefig(options.out, bbox_inches='tight')
    143164        else:
    144165                plt.show()
     166        end = time.time()
     167        print("Took {}".format(fmtDur(end - start)))
    145168
    146169
     
    156179        parser.add_argument('--logy', action='store_true', help="if set, makes the y-axis logscale")
    157180        parser.add_argument('--MaxY', nargs='?', type=int, help="maximum value of the y-axis")
     181        parser.add_argument('--filter', nargs='?', type=str, default="", help="if not empty, only print series that start with specified filter")
    158182
    159183        options =  parser.parse_args()
     184
     185        # if not options.out:
     186        #       matplotlib.use('SVG')
    160187
    161188        # ================================================================================
     
    179206                        fields.add(label)
    180207
    181         # find the common prefix on series for removal
     208        # filter out the series if needed
     209        if options.filter:
     210                series = set(filter(lambda elem: elem.startswith(options.filter), series))
     211
     212        # find the common prefix on series for removal (only if no filter)
    182213        prefix = os.path.commonprefix(list(series))
    183214
Note: See TracChangeset for help on using the changeset viewer.