-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgather_results.py
106 lines (75 loc) · 2.9 KB
/
gather_results.py
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import argparse
import os
import distutils
from distutils import dir_util
from parse_output import parse_output
from pprint import pprint
import csv
def mkdir_if_none_exits(path):
try:
os.mkdir(path)
except OSError as e:
if e.errno != os.errno.EEXIST:
raise
def doubling_range(start, stop):
while start < stop:
yield start
start <<= 1
def gather_test_results(test_dir):
print '\n@@ Gathering results from test dir: '+test_dir
results = []
slurm_outputs = [os.path.join(test_dir, filename) for filename in os.listdir(test_dir) if filename.startswith('slurm-')]
for out_file in slurm_outputs:
print '\n@@ Fetching results from out file: '+out_file
results.append(parse_output(out_file))
return results
def gather_mesh_results(mesh_dir):
print '\n@@ Gathering results from mesh dir: '+mesh_dir
results = []
n_procs = 2
test_dir = os.path.join(mesh_dir, str(n_procs)+'_procs')
while os.path.isdir(test_dir):
results += gather_test_results(test_dir)
n_procs <<= 1
test_dir = os.path.join(mesh_dir, str(n_procs)+'_procs')
return results
def gather_results(dir):
dir = os.path.abspath(dir)
print '\n@@ Tests directory: '+dir
results = []
mesh_dir = os.path.join(dir, 'x1_mesh')
if os.path.isdir(mesh_dir): # test case ran with mesh refinement
results += gather_mesh_results(mesh_dir)
mesh_dir = os.path.join(dir, 'x4_mesh')
if os.path.isdir(mesh_dir):
results += gather_mesh_results(mesh_dir)
mesh_dir = os.path.join(dir, 'x8_mesh')
if os.path.isdir(mesh_dir):
results += gather_mesh_results(mesh_dir)
else: # test case ran without mesh refinement
results += gather_mesh_results(dir)
return results
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Gathers the test results omited by an execution on the saling tester.')
parser.add_argument('-d',
dest='dir',
help='Path to the directory created by scaling tester containing the test results.')
args = parser.parse_args()
results = gather_results(args.dir)
print "\n@@ Writing results to test_results.csv"
with open(os.path.join(args.dir,'test_results.csv'), 'w') as results_file:
fieldnames = [
'Number of elements',
'Number of mpi processes',
'Total memory usage (MB)',
'Total execution time (sec)',
'Total cpu time (sec)',
'Number of time steps',
'Average time step (sec)',
'Elements per process'
]
writer = csv.DictWriter(results_file, fieldnames=fieldnames)
writer.writeheader()
for result in results:
writer.writerow(result)
print "\n@@ Done"