source: benchmark/plot.py @ 0bb691b1

ADTarm-ehast-experimentalenumforall-pointer-decayjacob/cs343-translationnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 0bb691b1 was 0bb691b1, checked in by Thierry Delisle <tdelisle@…>, 3 years ago

Adde script to plot results of rmit.py

  • Property mode set to 100755
File size: 2.5 KB
RevLine 
[0bb691b1]1#!/usr/bin/python3
2"""
3Python Script to plot values obtained by the rmit.py script
4Runs a R.I.P.L.
5
6./plot.py
7-t trials
8-o option:values
9"""
10
11import argparse
12import itertools
13import json
14import math
15import numpy
16import re
17import sys
18
19import matplotlib.pyplot as plt
20from matplotlib.ticker import EngFormatter
21
22def funit(name):
23        match = re.search("Number of (.*)", name)
24        if match:
25                return match.group(1).strip()
26
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"
40
41def plot(data, x, y):
42        fig, ax = plt.subplots()
43        colors = itertools.cycle(["r", "b", "g"])
44        series = {}
45        for entry in data:
46                if not entry[0] in series:
47                        series[entry[0]] = {'x':[], 'y':[]}
48
49                if x in entry[2] and y in entry[2]:
50                        series[entry[0]]['x'].append(entry[2][x])
51                        series[entry[0]]['y'].append(entry[2][y])
52
53        for name, data in series.items():
54                plt.scatter(data['x'], data['y'], color=next(colors), label=name, marker='x')
55
56        mx = max([max(s['x']) for s in series.values()])
57        my = max([max(s['y']) for s in series.values()])
58
59        plt.ylabel(y)
60        plt.xlim(0.75, mx + 0.25)
61        plt.xticks(range(1, math.ceil(mx) + 1))
62        plt.xlabel(x)
63        plt.ylim(0, my*1.2)
64        plt.grid(b = True)
65        formatter0 = EngFormatter(unit='Ops/s')
66        ax.yaxis.set_major_formatter(formatter0)
67        plt.legend()
68        plt.show()
69
70
71if __name__ == "__main__":
72        # ================================================================================
73        # parse command line arguments
74        parser = parser = argparse.ArgumentParser(description='Python Script to draw R.M.I.T. results')
75        parser.add_argument('-f', '--file', nargs='?', type=argparse.FileType('r'), default=sys.stdin)
76
77        try:
78                options =  parser.parse_args()
79        except:
80                print('ERROR: invalid arguments', file=sys.stderr)
81                parser.print_help(sys.stderr)
82                sys.exit(1)
83
84        # ================================================================================
85        # load data
86        try :
87                data = json.load(options.file)
88        except :
89                print('ERROR: could not read input', file=sys.stderr)
90                parser.print_help(sys.stderr)
91                sys.exit(1)
92
93        # ================================================================================
94        # identify the keys
95
96        series = set()
97        fields = set()
98
99        for entry in data:
100                series.add(entry[0])
101                for label in entry[2].keys():
102                        fields.add(label)
103
104        print(series)
105        print("fields")
106        for f in fields:
107                print("{} ({})".format(f, funit(f)))
108
109        plot(data, "Number of processors", "Ops per second")
Note: See TracBrowser for help on using the repository browser.