-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_plot.py
More file actions
executable file
·68 lines (52 loc) · 1.57 KB
/
Copy pathcreate_plot.py
File metadata and controls
executable file
·68 lines (52 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/python3
import glob
import csv
import numpy as np
import matplotlib.pyplot as plt
import scipy.optimize
def readlog(log):
with open(log, newline='') as csvfile:
spamreader = csv.reader(csvfile, delimiter=',')
arr=[[],[],[]]
for row in spamreader:
for i in range(len(row)):
arr[i].append(float(row[i]))
return arr
def mean (arr):
return np.mean(arr, axis=0)
def stdErr (arr):
return np.std(arr, axis=0) / np.sqrt(np.size(arr))
def removeIOTime (arr):
m = np.sort(arr)
return (m - m[0])
def monoExp(x, m, t, b):
return m * np.exp(t * x) + b
def fit(xs, ys):
p0 = (0, 1, 1)
params, cv = scipy.optimize.curve_fit(monoExp, xs, ys, p0)
m, t, b = params
return (m,t,b)
def fitSeries(arr, yerr, lab=""):
n = len(arr)
xs = np.arange(n)
ys = arr
(m,t,b) = fit(xs, ys)
plt.errorbar(xs, ys, yerr=yerr, fmt = '.', label=lab+" data")
xss = np.linspace(0,(n-1)*1.01)
plt.plot(xss, monoExp(xss, m, t, b), '--', label=lab+" fitted")
logfiles = glob.glob("./*.log")
sifun = [readlog(log)[0] for log in logfiles]
haskell = [readlog(log)[1] for log in logfiles]
sifunMean = mean(sifun)
haskellMean = mean(haskell)
sifunStdErr = stdErr(sifun)
haskellStdErr = stdErr(haskell)
sifunMeanNoIO = removeIOTime(sifunMean)
haskellMeanNoIO = removeIOTime(haskellMean)
fitSeries(sifunMeanNoIO, sifunStdErr, "sifun")
fitSeries(haskellMeanNoIO, haskellStdErr, "haskell")
plt.legend(loc="upper left")
plt.title("Fitted Exponential Curves for SiFun and Haskell")
plt.xlabel("test size - binary tree height")
plt.ylabel("execution time [s]")
plt.show()