source: doc/theses/colby_parsons_MMAth/benchmarks/channels/plotData.py @ ad47ec4

Last change on this file since ad47ec4 was 14e1053, checked in by caparsons <caparson@…>, 17 months ago

first draft of full waituntil chapter and conclusion chapter. Lots of graph/plotting utilities cleanup. Reran all CFA actor benchmarks after recent changes. Small changes to actor.tex in performance section

  • Property mode set to 100644
File size: 4.6 KB
RevLine 
[2f6a9391]1import os
2import sys
3import time
[4912520]4import itertools
[2f6a9391]5import matplotlib.pyplot as plt
6import matplotlib.ticker as ticks
7import math
8from scipy import stats as st
9import numpy as np
10from enum import Enum
11from statistics import median
12
13import matplotlib
14matplotlib.use("pgf")
15matplotlib.rcParams.update({
16    "pgf.texsystem": "pdflatex",
17    'font.family': 'serif',
18    'text.usetex': True,
19    'pgf.rcfonts': False,
[4912520]20    'font.size': 16
[2f6a9391]21})
[14e1053]22marker = itertools.cycle(('o', 's', 'D', 'x', 'p', '^', 'h', '*', 'v' ))
23
24def sci_format(x, pos):
25    return '{:.1e}'.format(x).replace('+0', '')
[2f6a9391]26
27readfile = open(sys.argv[1], "r")
28
29machineName = ""
30
31if len(sys.argv) > 2:
32    machineName = sys.argv[2]
33
34# first line has num times per experiment
35line = readfile.readline()
36numTimes = int(line)
37
38# second line has processor args
39line = readfile.readline()
40procs = []
41for val in line.split():
42    procs.append(int(val))
43
[d24b1985]44# 3rd line has number of variants
[2f6a9391]45line = readfile.readline()
46names = line.split()
47numVariants = len(names)
48
49lines = (line.rstrip() for line in readfile) # All lines including the blank ones
50lines = (line for line in lines if line) # Non-blank lines
51
[d24b1985]52class Bench(Enum):
53    Unset = 0
54    Contend = 1
55    Zero = 2
56    Barrier = 3
57    Churn = 4
58    Daisy_Chain = 5
59    Hot_Potato = 6
60    Pub_Sub = 7
61
[2f6a9391]62nameSet = False
[d24b1985]63currBench = Bench.Unset # default val
[2f6a9391]64count = 0
65procCount = 0
66currVariant = 0
[14e1053]67experiment_duration = 10.0
[d24b1985]68name = ""
[14e1053]69title = ""
[2f6a9391]70var_name = ""
71sendData = [0.0 for j in range(numVariants)]
72data = [[0.0 for i in range(len(procs))] for j in range(numVariants)]
73bars = [[[0.0 for i in range(len(procs))],[0.0 for k in range(len(procs))]] for j in range(numVariants)]
74tempData = [0.0 for i in range(numTimes)]
75for idx, line in enumerate(lines):
76    # print(line)
77   
[d24b1985]78    if currBench == Bench.Unset:
79        if line == "contend:":
[14e1053]80            name = "Channel_Contention"
81            title = "Channel Contention"
[d24b1985]82            currBench = Bench.Contend
83        elif line == "zero:":
84            name = "Zero"
85            currBench = Bench.Zero
86        elif line == "barrier:":
87            name = "Barrier"
88            currBench = Bench.Barrier
89        elif line == "churn:":
90            name = "Churn"
91            currBench = Bench.Churn
92        elif line == "daisy_chain:":
93            name = "Daisy_Chain"
94            currBench = Bench.Daisy_Chain
95        elif line == "hot_potato:":
96            name = "Hot_Potato"
97            currBench = Bench.Hot_Potato
98        elif line == "pub_sub:":
99            name = "Pub_Sub"
100            currBench = Bench.Pub_Sub
101        else:
102            print("Expected benchmark name")
103            print("Line: " + line)
104            sys.exit()
[2f6a9391]105        continue
106
107    if line[0:5] == "cores":
108        continue
109
110    if not nameSet:
111        nameSet = True
112        continue
113   
114    lineArr = line.split()
[917e1fd]115    tempData[count] = float(lineArr[-1]) / experiment_duration
[2f6a9391]116    count += 1
117    if count == numTimes:
118        currMedian = median( tempData )
119        data[currVariant][procCount] = currMedian
120        lower, upper = st.t.interval(0.95, numTimes - 1, loc=np.mean(tempData), scale=st.sem(tempData))
121        bars[currVariant][0][procCount] = currMedian - lower
122        bars[currVariant][1][procCount] = upper - currMedian
123        count = 0
124        procCount += 1
125
126        if procCount == len(procs):
127            procCount = 0
128            nameSet = False
129            currVariant += 1
130
131            if currVariant == numVariants:
[1803d4d]132                fig, ax = plt.subplots(layout='constrained')
[14e1053]133                if title != "":
134                    plt.title(title + " Benchmark")
135                    title = ""
136                else:
137                    plt.title(name + " Benchmark")
138                plt.ylabel("Throughput (channel operations per second)")
[2f6a9391]139                plt.xlabel("Cores")
[14e1053]140                ax.yaxis.set_major_formatter(ticks.FuncFormatter(sci_format))
[2f6a9391]141                for idx, arr in enumerate(data):
[4912520]142                    plt.errorbar( procs, arr, [bars[idx][0], bars[idx][1]], capsize=2, marker=next(marker) )
[60f4919]143                marker = itertools.cycle(('o', 's', 'D', 'x', 'p', '^', 'h', '*', 'v' )) 
[14e1053]144                # plt.yscale("log")
[d24b1985]145                # plt.ylim(1, None)
146                # ax.get_yaxis().set_major_formatter(ticks.ScalarFormatter())
147                # else:
148                #     plt.ylim(0, None)
[2f6a9391]149                plt.xticks(procs)
150                ax.legend(names)
[d24b1985]151                # fig.savefig("plots/" + machineName + name + ".png")
152                plt.savefig("plots/" + machineName + name + ".pgf")
[2f6a9391]153                fig.clf()
154
155                # reset
[d24b1985]156                currBench = Bench.Unset
[2f6a9391]157                currVariant = 0
Note: See TracBrowser for help on using the repository browser.