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

Last change on this file since f9ad69d was 14e1053, checked in by caparsons <caparson@…>, 17 months ago

first draft of full waituntil chapter and conclusion chapter. Lots of graph/plotting utilities cleanup. Reran all CFA actor benchmarks after recent changes. Small changes to actor.tex in performance section

  • Property mode set to 100644
File size: 3.4 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 = ""
62experiment_duration = 10.0
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 currLocks == -1:
71        lineArr = line.split()
72        currLocks = lineArr[-1]
73        continue
74
75    if line[0:5] == "cores":
76        continue
77
78    if not nameSet:
79        nameSet = True
80        continue
81   
82    lineArr = line.split()
83    tempData[count] = float(lineArr[-1]) / experiment_duration
84    count += 1
85    if count == numTimes:
86        currMedian = median( tempData )
87        data[currVariant][procCount] = currMedian
88        lower, upper = st.t.interval(0.95, numTimes - 1, loc=np.mean(tempData), scale=st.sem(tempData))
89        bars[currVariant][0][procCount] = max( 0, currMedian - lower )
90        bars[currVariant][1][procCount] = max( 0, upper - currMedian )
91        count = 0
92        procCount += 1
93
94        if procCount == len(procs):
95            procCount = 0
96            nameSet = False
97            currVariant += 1
98
99            if currVariant == numVariants:
100                fig, ax = plt.subplots(layout='constrained')
101                plt.title(name + " Benchmark: " + str(currLocks) + " Locks")
102                plt.ylabel("Throughput (critical section entries per second)")
103                plt.xlabel("Cores")
104                for idx, arr in enumerate(data):
105                    plt.errorbar( procs, arr, [bars[idx][0], bars[idx][1]], capsize=2, marker=next(marker) )
106                marker = itertools.cycle(('o', 's', 'D', 'x', 'p', '^', 'h', '*', 'v' )) 
107                plt.yscale("log")
108                plt.xticks(procs)
109                ax.legend(names)
110                # fig.savefig("plots/" + machineName + "Aggregate_Lock_" + str(currLocks) + ".png")
111                plt.savefig("plots/" + machineName + "Aggregate_Lock_" + str(currLocks) + ".pgf")
112                fig.clf()
113
114                # reset
115                currLocks = -1
116                currVariant = 0
Note: See TracBrowser for help on using the repository browser.