1 | import os |
---|
2 | import sys |
---|
3 | import time |
---|
4 | import itertools |
---|
5 | import matplotlib.pyplot as plt |
---|
6 | import matplotlib.ticker as ticks |
---|
7 | import math |
---|
8 | from scipy import stats as st |
---|
9 | import numpy as np |
---|
10 | from enum import Enum |
---|
11 | from statistics import median |
---|
12 | |
---|
13 | import matplotlib |
---|
14 | matplotlib.use("pgf") |
---|
15 | matplotlib.rcParams.update({ |
---|
16 | "pgf.texsystem": "pdflatex", |
---|
17 | 'font.family': 'serif', |
---|
18 | 'text.usetex': True, |
---|
19 | 'pgf.rcfonts': False, |
---|
20 | 'font.size': 16 |
---|
21 | }) |
---|
22 | marker = itertools.cycle(('o', 's', 'D', 'x', 'p', '^', 'h', '*', 'v' )) |
---|
23 | |
---|
24 | readfile = open(sys.argv[1], "r") |
---|
25 | |
---|
26 | machineName = "" |
---|
27 | |
---|
28 | if len(sys.argv) > 2: |
---|
29 | machineName = sys.argv[2] |
---|
30 | |
---|
31 | # first line has num times per experiment |
---|
32 | line = readfile.readline() |
---|
33 | numTimes = int(line) |
---|
34 | |
---|
35 | # second line has processor args |
---|
36 | line = readfile.readline() |
---|
37 | procs = [] |
---|
38 | for val in line.split(): |
---|
39 | procs.append(int(val)) |
---|
40 | |
---|
41 | # 3rd line has num locks args |
---|
42 | line = readfile.readline() |
---|
43 | locks = [] |
---|
44 | for val in line.split(): |
---|
45 | locks.append(int(val)) |
---|
46 | |
---|
47 | # 4th line has number of variants |
---|
48 | line = readfile.readline() |
---|
49 | names = line.split() |
---|
50 | numVariants = len(names) |
---|
51 | |
---|
52 | lines = (line.rstrip() for line in readfile) # All lines including the blank ones |
---|
53 | lines = (line for line in lines if line) # Non-blank lines |
---|
54 | |
---|
55 | nameSet = False |
---|
56 | currLocks = -1 # default val |
---|
57 | count = 0 |
---|
58 | procCount = 0 |
---|
59 | currVariant = 0 |
---|
60 | name = "Aggregate Lock" |
---|
61 | var_name = "" |
---|
62 | sendData = [0.0 for j in range(numVariants)] |
---|
63 | data = [[0.0 for i in range(len(procs))] for j in range(numVariants)] |
---|
64 | bars = [[[0.0 for i in range(len(procs))],[0.0 for k in range(len(procs))]] for j in range(numVariants)] |
---|
65 | tempData = [0.0 for i in range(numTimes)] |
---|
66 | for 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(layout='constrained') |
---|
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 | marker = itertools.cycle(('o', 's', 'D', 'x', 'p', '^', 'h', '*', 'v' )) |
---|
106 | plt.yscale("log") |
---|
107 | plt.xticks(procs) |
---|
108 | ax.legend(names) |
---|
109 | # fig.savefig("plots/" + machineName + "Aggregate_Lock_" + str(currLocks) + ".png") |
---|
110 | plt.savefig("plots/" + machineName + "Aggregate_Lock_" + str(currLocks) + ".pgf") |
---|
111 | fig.clf() |
---|
112 | |
---|
113 | # reset |
---|
114 | currLocks = -1 |
---|
115 | currVariant = 0 |
---|