Changeset f4fe7fd for benchmark


Ignore:
Timestamp:
Apr 26, 2022, 5:46:51 PM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
5cd0742
Parents:
b81ab1c6 (diff), ed49dbd (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

    rb81ab1c6 rf4fe7fd  
    1515import numpy
    1616import re
     17import statistics
    1718import sys
    1819
     
    4041}
    4142
    42 def plot(data, x, y, out):
     43def plot(in_data, x, y, out):
    4344        fig, ax = plt.subplots()
    4445        colors = itertools.cycle(['#0095e3','#006cb4','#69df00','#0aa000','#fb0300','#e30002','#fd8f00','#ff7f00','#8f00d6','#4b009a','#ffff00','#b13f00'])
    45         series = {}
    46         for entry in data:
    47                 if not entry[0] in series:
    48                         series[entry[0]] = {'x':[], 'y':[]}
     46        series = {} # scatter data for each individual data point
     47        groups = {} # data points for x value
     48        for entry in in_data:
     49                name = entry[0]
     50                if not name in series:
     51                        series[name] = {'x':[], 'y':[]}
     52
     53                if not name in groups:
     54                        groups[name] = {}
    4955
    5056                if x in entry[2] and y in entry[2]:
    51                         series[entry[0]]['x'].append(entry[2][x])
    52                         series[entry[0]]['y'].append(entry[2][y])
     57                        xval = entry[2][x]
     58                        yval = entry[2][y]
     59                        series[name]['x'].append(xval)
     60                        series[name]['y'].append(yval)
     61
     62                        if not xval in groups[name]:
     63                                groups[name][xval] = []
     64
     65                        groups[name][xval].append(yval)
     66
     67        lines = {} # lines from groups with min, max, median, etc.
     68        for name, data in groups.items():
     69                if not name in lines:
     70                        lines[name] = { 'x': [], 'min':[], 'max':[], 'med':[], 'avg':[] }
     71
     72                for xkey in sorted(data):
     73                        ys = data[xkey]
     74                        lines[name]['x']  .append(xkey)
     75                        lines[name]['min'].append(min(ys))
     76                        lines[name]['max'].append(max(ys))
     77                        lines[name]['med'].append(statistics.median(ys))
     78                        lines[name]['avg'].append(statistics.mean(ys))
    5379
    5480        for name, data in series.items():
    55                 plt.scatter(data['x'], data['y'], color=next(colors), label=name, marker='x')
     81                _col = next(colors)
     82                plt.scatter(data['x'], data['y'], color=_col, label=name, marker='x')
     83                plt.plot(lines[name]['x'], lines[name]['min'], '--', color=_col)
     84                plt.plot(lines[name]['x'], lines[name]['max'], '--', color=_col)
     85                plt.plot(lines[name]['x'], lines[name]['med'], '-', color=_col)
    5686
    5787        mx = max([max(s['x']) for s in series.values()])
Note: See TracChangeset for help on using the changeset viewer.