-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnew_save2file.py
47 lines (35 loc) · 1.64 KB
/
new_save2file.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
import pandas as pd
import re
# Path of the latest uploaded file
latest_file_path = './results.txt'
# Reading the contents of the latest uploaded file
with open(latest_file_path, 'r') as file:
latest_content = file.read()
# Regular expressions used for parsing
algo_bconfig_pattern_updated = re.compile(r'Running with --algo=(\d) --bconfig=(\d+)')
performance_pattern_refined = re.compile(r'Average elapsed time: \(([\d.]+)\) s, performance: \(\s*([\d.]+)\) GIPS')
# Parsing logic
latest_refined_results = []
for section in latest_content.split("---------------------------------------"):
algo_bconfig_match = algo_bconfig_pattern_updated.search(section)
performance_match = performance_pattern_refined.search(section)
if algo_bconfig_match and performance_match:
algo = int(algo_bconfig_match.group(1))
bconfig = int(algo_bconfig_match.group(2))
performance = float(performance_match.group(2))
latest_refined_results.append({
"algo": algo,
"bconfig": bconfig,
"performance": performance
})
# Converting the parsed results into a DataFrame
df_latest_refined_results = pd.DataFrame(latest_refined_results)
# Pivoting the DataFrame
pivot_df = df_latest_refined_results.pivot(index='algo', columns='bconfig', values='performance')
# Renaming the columns to a more descriptive format
pivot_df.columns = ['bconfig = ' + str(col) for col in pivot_df.columns]
# Saving the pivoted data to a CSV file
latest_csv_file_path = './pivoted_performance_results_latest.csv'
pivot_df.to_csv(latest_csv_file_path, index=True)
# Output path of the CSV file
latest_csv_file_path