| 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 | experiment_duration = 10.0
|
|---|
| 63 | sendData = [0.0 for j in range(numVariants)]
|
|---|
| 64 | data = [[0.0 for i in range(len(procs))] for j in range(numVariants)]
|
|---|
| 65 | bars = [[[0.0 for i in range(len(procs))],[0.0 for k in range(len(procs))]] for j in range(numVariants)]
|
|---|
| 66 | tempData = [0.0 for i in range(numTimes)]
|
|---|
| 67 | for 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
|
|---|