1 | import os
|
---|
2 | import sys
|
---|
3 | import time
|
---|
4 | import matplotlib.pyplot as plt
|
---|
5 | import matplotlib.ticker as ticks
|
---|
6 | import math
|
---|
7 | from scipy import stats as st
|
---|
8 | import numpy as np
|
---|
9 | from enum import Enum
|
---|
10 | from statistics import median
|
---|
11 |
|
---|
12 | import matplotlib
|
---|
13 | matplotlib.use("pgf")
|
---|
14 | matplotlib.rcParams.update({
|
---|
15 | "pgf.texsystem": "pdflatex",
|
---|
16 | 'font.family': 'serif',
|
---|
17 | 'text.usetex': True,
|
---|
18 | 'pgf.rcfonts': False,
|
---|
19 | })
|
---|
20 |
|
---|
21 | readfile = open(sys.argv[1], "r")
|
---|
22 |
|
---|
23 | machineName = ""
|
---|
24 |
|
---|
25 | if len(sys.argv) > 2:
|
---|
26 | machineName = sys.argv[2]
|
---|
27 |
|
---|
28 | # first line has num times per experiment
|
---|
29 | line = readfile.readline()
|
---|
30 | numTimes = int(line)
|
---|
31 |
|
---|
32 | # second line has processor args
|
---|
33 | line = readfile.readline()
|
---|
34 | procs = []
|
---|
35 | for val in line.split():
|
---|
36 | procs.append(int(val))
|
---|
37 |
|
---|
38 | # 3rd line has num locks args
|
---|
39 | line = readfile.readline()
|
---|
40 | locks = []
|
---|
41 | for val in line.split():
|
---|
42 | locks.append(int(val))
|
---|
43 |
|
---|
44 | # 4th line has number of variants
|
---|
45 | line = readfile.readline()
|
---|
46 | names = line.split()
|
---|
47 | numVariants = len(names)
|
---|
48 |
|
---|
49 | lines = (line.rstrip() for line in readfile) # All lines including the blank ones
|
---|
50 | lines = (line for line in lines if line) # Non-blank lines
|
---|
51 |
|
---|
52 | nameSet = False
|
---|
53 | currLocks = -1 # default val
|
---|
54 | count = 0
|
---|
55 | procCount = 0
|
---|
56 | currVariant = 0
|
---|
57 | name = "Aggregate Lock"
|
---|
58 | var_name = ""
|
---|
59 | sendData = [0.0 for j in range(numVariants)]
|
---|
60 | data = [[0.0 for i in range(len(procs))] for j in range(numVariants)]
|
---|
61 | bars = [[[0.0 for i in range(len(procs))],[0.0 for k in range(len(procs))]] for j in range(numVariants)]
|
---|
62 | tempData = [0.0 for i in range(numTimes)]
|
---|
63 | for idx, line in enumerate(lines):
|
---|
64 | # print(line)
|
---|
65 |
|
---|
66 | if currLocks == -1:
|
---|
67 | lineArr = line.split()
|
---|
68 | currLocks = lineArr[-1]
|
---|
69 | continue
|
---|
70 |
|
---|
71 | if line[0:5] == "cores":
|
---|
72 | continue
|
---|
73 |
|
---|
74 | if not nameSet:
|
---|
75 | nameSet = True
|
---|
76 | continue
|
---|
77 |
|
---|
78 | lineArr = line.split()
|
---|
79 | tempData[count] = float(lineArr[-1])
|
---|
80 | count += 1
|
---|
81 | if count == numTimes:
|
---|
82 | currMedian = median( tempData )
|
---|
83 | data[currVariant][procCount] = currMedian
|
---|
84 | lower, upper = st.t.interval(0.95, numTimes - 1, loc=np.mean(tempData), scale=st.sem(tempData))
|
---|
85 | bars[currVariant][0][procCount] = currMedian - lower
|
---|
86 | bars[currVariant][1][procCount] = upper - currMedian
|
---|
87 | count = 0
|
---|
88 | procCount += 1
|
---|
89 |
|
---|
90 | if procCount == len(procs):
|
---|
91 | procCount = 0
|
---|
92 | nameSet = False
|
---|
93 | currVariant += 1
|
---|
94 |
|
---|
95 | if currVariant == numVariants:
|
---|
96 | fig, ax = plt.subplots()
|
---|
97 | plt.title(name + " Benchmark: " + str(currLocks) + " Locks")
|
---|
98 | plt.ylabel("Throughput (entries)")
|
---|
99 | plt.xlabel("Cores")
|
---|
100 | for idx, arr in enumerate(data):
|
---|
101 | plt.errorbar( procs, arr, [bars[idx][0], bars[idx][1]], capsize=2, marker='o' )
|
---|
102 | plt.yscale("log")
|
---|
103 | plt.xticks(procs)
|
---|
104 | ax.legend(names)
|
---|
105 | # fig.savefig("plots/" + machineName + "Aggregate_Lock_" + str(currLocks) + ".png")
|
---|
106 | plt.savefig("plots/" + machineName + "Aggregate_Lock_" + str(currLocks) + ".pgf")
|
---|
107 | fig.clf()
|
---|
108 |
|
---|
109 | # reset
|
---|
110 | currLocks = -1
|
---|
111 | currVariant = 0
|
---|