diff --git a/A2/graph/performance.py b/A2/graph/performance.py index 6a098b3..c62817d 100755 --- a/A2/graph/performance.py +++ b/A2/graph/performance.py @@ -1,40 +1,46 @@ #!/usr/bin/python import os import numpy as np from numpy import array testdir = "tests" os.system("mkdir -p " + testdir) Ntr = [1, 2, 4, 8, 16] #sample = "Running the algorithm with 4 threads on 10000 by 10000 array for 5 iterations took 1.547 seconds" def loadtimes(fstream): t = [] for line in fstream: # skip if no information is contained if not line.startswith("Running the algorithm"): continue values = line.split(' ') # split into string set values = [i for i in values if i != ''] # fliter null strings t.append(float(values[15])) # 16-th value should contain the elapsed time return t T = [] # times +S = [] # speedups for filename in os.listdir(os.getcwd() + '/' + testdir): with open(os.path.join(os.getcwd() + '/' + testdir, filename), 'r') as f: t = np.array(loadtimes(f)) T.append(t) + t0 = t[0] + S.append(t0 / t) Tmean = np.mean(T, axis=0).tolist() Tsq = np.sqrt(np.var(T, axis=0)).tolist() # compute mean and variance of arrays +Smean = np.mean(S, axis=0).tolist() +Ssq = np.sqrt(np.var(S, axis=0)).tolist() # compute mean and variance of arrays + # output values out = open("times.txt", 'w') -print("ntr t dt", file=out) -for (ntr, t, dt) in zip(Ntr, Tmean, Tsq): - print("%d %.3g %.3g" % (ntr, t, dt), file=out) +print("ntr t dt s ds", file=out) +for (ntr, t, dt, s, ds) in zip(Ntr, Tmean, Tsq, Smean, Ssq): + print("%d %.3g %.3g %.3g %.3g" % (ntr, t, dt, s, ds), file=out) out.close() diff --git a/A2/graph/times.txt b/A2/graph/times.txt index b5b9d59..7dc2b0c 100644 --- a/A2/graph/times.txt +++ b/A2/graph/times.txt @@ -1,6 +1,6 @@ -ntr t dt -1 1.55 0 -2 1.55 0 -4 1.55 0 -8 1.55 0 -16 1.55 0 +ntr t dt s ds +1 49.2 7.31 1 0 +2 25 3.5 1.97 0.0408 +4 12.6 1.6 3.88 0.108 +8 6.72 1.01 7.38 0.818 +16 5.06 1.4 10.3 2.53