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

stuck-waitfor-destruct
Last change on this file since b9c06b98 was 917e1fd, checked in by caparson <caparson@…>, 3 years ago

changed throughput in plotting script to be per second not per 10 seconds

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