-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile_memory_cpp.py
39 lines (25 loc) · 1005 Bytes
/
profile_memory_cpp.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
#!/usr/bin/env python3
from util import get_matrix_list, monitor_memory
import subprocess
import csv
import os
os.chdir("cpp")
matrices_dir = "matrices"
file_list, matrix_list = get_matrix_list(matrices_dir, ".mtx.gz")
cpp_path = "cmake-build-release/cholesky-cpp"
with open('output/cppOutput.csv', 'w') as output_csv:
writer = csv.writer(output_csv, delimiter=',')
writer.writerow(['name', 'rows', 'nonZeros', 'loadTime', 'solveTime', 'relativeError', 'maxMemory', 'memoryUsage'])
for i in range(len(file_list)):
file_name = file_list[i]
matrix_name = matrix_list[i]
command = [cpp_path, file_name]
subproc = subprocess.Popen(command, stdout=subprocess.PIPE, encoding="utf-8")
max_memory, memory_usage = monitor_memory(subproc)
reader = csv.reader(subproc.stdout)
row = next(reader)
row.append(max_memory)
row.append(memory_usage)
writer.writerow(row)
output_csv.flush()
output_csv.close()