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

ADT ast-experimental
Last change on this file since bb7422a was d24b1985, checked in by caparson <caparson@…>, 2 years ago

updated plotting and run scripts for channel benchmarks

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