forked from cerati/p2z-tests
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_processing.py
More file actions
52 lines (42 loc) · 2.08 KB
/
data_processing.py
File metadata and controls
52 lines (42 loc) · 2.08 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
from os import scandir
functions_list = open("Functions.txt", "r") # Open the functions file
content = []
for line in functions_list:
tmp = line.strip()
content.append(tmp)
# print(content)
files = ["data"] # This list takes in the list of files we want to process
parsed_data_files = [0] * len(files)
for i in range(len(files)):
parsed_data_files[i] = open(files[i] +".csv", "r") # Open the .csv file(s) for processing.
function_inclusive = []
# This for loop gets the inclusive/exclusive time for the functions and stores it in a list
for i in range(len(files)):
tmp = {}
for line in parsed_data_files[i]:
line = line.split(",")
if ".TAU application" in line[3]:
for j in range(len(content)):
if content[j] in line[3]:
tmp[content[j]] = line[len(line) - 1].strip()
# function_inclusive[i][content[j]] = line[len(line) - 1].strip()
break
dictionary_items = tmp.items()
sorted_items = sorted(dictionary_items)
function_inclusive.append(sorted_items)
# print(function_inclusive)
# This code calculates the ratios for each size (128B, 256B, 512B, scalar).
if(len(files) == 4):
results = []
for j in range(len(content)):
tmp = {}
total = int(function_inclusive[0][j][1]) + int(function_inclusive[1][j][1]) + int(function_inclusive[2][j][1]) + int(function_inclusive[3][j][1])
res_128B = int(function_inclusive[0][j][1])/int(total)
res_256B = int(function_inclusive[1][j][1])/int(total)
res_512B = int(function_inclusive[2][j][1])/int(total)
res_scalar = int(function_inclusive[3][j][1])/int(total)
tmp[function_inclusive[0][j][0]] = [res_128B, res_256B, res_512B, res_scalar]
results.append(tmp)
print(results) # A list of dictionaries containing the ratios with the function as the key, and ratios as the value. The values are in the following order: 128B, 256B, 512B, Scalar
else:
print(function_inclusive)