Page MenuHomec4science

performance.py
No OneTemporary

File Metadata

Created
Sun, Nov 17, 16:19

performance.py

#!/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
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)
Tmean = np.mean(T, axis=0).tolist()
Tsq = np.sqrt(np.var(T, 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)
out.close()

Event Timeline