source: doc/theses/colby_parsons_MMAth/benchmarks/mutex_stmt/plotData.py@ 382467f

ast-experimental
Last change on this file since 382467f was 4912520, checked in by caparsons <caparson@…>, 2 years ago

updated plotting scripts with new plot style

  • Property mode set to 100644
File size: 3.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 num locks args
42line = readfile.readline()
43locks = []
44for val in line.split():
45 locks.append(int(val))
46
47# 4th line has number of variants
48line = readfile.readline()
49names = line.split()
50numVariants = len(names)
51
52lines = (line.rstrip() for line in readfile) # All lines including the blank ones
53lines = (line for line in lines if line) # Non-blank lines
54
55nameSet = False
56currLocks = -1 # default val
57count = 0
58procCount = 0
59currVariant = 0
60name = "Aggregate Lock"
61var_name = ""
62sendData = [0.0 for j in range(numVariants)]
63data = [[0.0 for i in range(len(procs))] for j in range(numVariants)]
64bars = [[[0.0 for i in range(len(procs))],[0.0 for k in range(len(procs))]] for j in range(numVariants)]
65tempData = [0.0 for i in range(numTimes)]
66for idx, line in enumerate(lines):
67 # print(line)
68
69 if currLocks == -1:
70 lineArr = line.split()
71 currLocks = lineArr[-1]
72 continue
73
74 if line[0:5] == "cores":
75 continue
76
77 if not nameSet:
78 nameSet = True
79 continue
80
81 lineArr = line.split()
82 tempData[count] = float(lineArr[-1])
83 count += 1
84 if count == numTimes:
85 currMedian = median( tempData )
86 data[currVariant][procCount] = currMedian
87 lower, upper = st.t.interval(0.95, numTimes - 1, loc=np.mean(tempData), scale=st.sem(tempData))
88 bars[currVariant][0][procCount] = currMedian - lower
89 bars[currVariant][1][procCount] = upper - currMedian
90 count = 0
91 procCount += 1
92
93 if procCount == len(procs):
94 procCount = 0
95 nameSet = False
96 currVariant += 1
97
98 if currVariant == numVariants:
99 fig, ax = plt.subplots()
100 plt.title(name + " Benchmark: " + str(currLocks) + " Locks")
101 plt.ylabel("Throughput (entries)")
102 plt.xlabel("Cores")
103 for idx, arr in enumerate(data):
104 plt.errorbar( procs, arr, [bars[idx][0], bars[idx][1]], capsize=2, marker=next(marker) )
105 plt.yscale("log")
106 plt.xticks(procs)
107 ax.legend(names)
108 # fig.savefig("plots/" + machineName + "Aggregate_Lock_" + str(currLocks) + ".png")
109 plt.savefig("plots/" + machineName + "Aggregate_Lock_" + str(currLocks) + ".pgf")
110 fig.clf()
111
112 # reset
113 currLocks = -1
114 currVariant = 0
Note: See TracBrowser for help on using the repository browser.