|
5 | 5 | import csv |
6 | 6 |
|
7 | 7 | parser = argparse.ArgumentParser() |
8 | | -parser.add_argument('-i', '--input', help='Input file path (logs of perf tests, .txt)', required=True) |
9 | | -parser.add_argument('-o', '--output', help='Output file path (path to .xlsx table)', required=True) |
| 8 | +parser.add_argument( |
| 9 | + "-i", "--input", help="Input file path (logs of perf tests, .txt)", required=True |
| 10 | +) |
| 11 | +parser.add_argument( |
| 12 | + "-o", "--output", help="Output file path (path to .xlsx table)", required=True |
| 13 | +) |
10 | 14 | args = parser.parse_args() |
11 | 15 | logs_path = os.path.abspath(args.input) |
12 | 16 | xlsx_path = os.path.abspath(args.output) |
|
19 | 23 | logs_file = open(logs_path, "r") |
20 | 24 | logs_lines = logs_file.readlines() |
21 | 25 | for line in logs_lines: |
22 | | - pattern = r'tasks[\/|\\](\w*)[\/|\\](\w*):(\w*):(-*\d*\.\d*)' |
| 26 | + pattern = r"tasks[\/|\\](\w*)[\/|\\](\w*):(\w*):(-*\d*\.\d*)" |
23 | 27 | result = re.findall(pattern, line) |
24 | 28 | if len(result): |
25 | 29 | task_name = result[0][1] |
|
31 | 35 | result_tables[perf_type][task_name][ttype] = -1.0 |
32 | 36 |
|
33 | 37 | for line in logs_lines: |
34 | | - pattern = r'tasks[\/|\\](\w*)[\/|\\](\w*):(\w*):(-*\d*\.\d*)' |
| 38 | + pattern = r"tasks[\/|\\](\w*)[\/|\\](\w*):(\w*):(-*\d*\.\d*)" |
35 | 39 | result = re.findall(pattern, line) |
36 | 40 | if len(result): |
37 | 41 | task_type = result[0][0] |
|
45 | 49 |
|
46 | 50 |
|
47 | 51 | for table_name in result_tables: |
48 | | - workbook = xlsxwriter.Workbook(os.path.join(xlsx_path, table_name + '_perf_table.xlsx')) |
| 52 | + workbook = xlsxwriter.Workbook( |
| 53 | + os.path.join(xlsx_path, table_name + "_perf_table.xlsx") |
| 54 | + ) |
49 | 55 | worksheet = workbook.add_worksheet() |
50 | | - worksheet.set_column('A:Z', 23) |
51 | | - right_bold_border = workbook.add_format({'bold': True, 'right': 2, 'bottom': 2}) |
52 | | - bottom_bold_border = workbook.add_format({'bold': True, 'bottom': 2}) |
| 56 | + worksheet.set_column("A:Z", 23) |
| 57 | + right_bold_border = workbook.add_format({"bold": True, "right": 2, "bottom": 2}) |
| 58 | + bottom_bold_border = workbook.add_format({"bold": True, "bottom": 2}) |
53 | 59 | cpu_num = os.environ.get("PPC_NUM_PROC") |
54 | 60 | if cpu_num is None: |
55 | | - raise EnvironmentError("Required environment variable 'PPC_NUM_PROC' is not set.") |
| 61 | + raise EnvironmentError( |
| 62 | + "Required environment variable 'PPC_NUM_PROC' is not set." |
| 63 | + ) |
56 | 64 | cpu_num = int(cpu_num) |
57 | 65 | worksheet.write(0, 0, "cpu_num = " + str(cpu_num), right_bold_border) |
58 | 66 |
|
59 | 67 | it = 1 |
60 | 68 | for type_of_task in list_of_type_of_tasks: |
61 | | - worksheet.write(0, it, "T_" + type_of_task + "(" + str(cpu_num) + ")", bottom_bold_border) |
| 69 | + worksheet.write( |
| 70 | + 0, it, "T_" + type_of_task + "(" + str(cpu_num) + ")", bottom_bold_border |
| 71 | + ) |
62 | 72 | it += 1 |
63 | | - worksheet.write(0, it, "S(" + str(cpu_num) + ")" + " = " + |
64 | | - "T_seq(" + str(cpu_num) + ")" + " / " + |
65 | | - "T_" + type_of_task + "(" + str(cpu_num) + ")", bottom_bold_border) |
| 73 | + worksheet.write( |
| 74 | + 0, |
| 75 | + it, |
| 76 | + "S(" |
| 77 | + + str(cpu_num) |
| 78 | + + ")" |
| 79 | + + " = " |
| 80 | + + "T_seq(" |
| 81 | + + str(cpu_num) |
| 82 | + + ")" |
| 83 | + + " / " |
| 84 | + + "T_" |
| 85 | + + type_of_task |
| 86 | + + "(" |
| 87 | + + str(cpu_num) |
| 88 | + + ")", |
| 89 | + bottom_bold_border, |
| 90 | + ) |
66 | 91 | it += 1 |
67 | | - worksheet.write(0, it, "Eff(" + str(cpu_num) + ")" + " = " + |
68 | | - "S(" + str(cpu_num) + ")" + " / " + str(cpu_num), right_bold_border) |
| 92 | + worksheet.write( |
| 93 | + 0, |
| 94 | + it, |
| 95 | + "Eff(" |
| 96 | + + str(cpu_num) |
| 97 | + + ")" |
| 98 | + + " = " |
| 99 | + + "S(" |
| 100 | + + str(cpu_num) |
| 101 | + + ")" |
| 102 | + + " / " |
| 103 | + + str(cpu_num), |
| 104 | + right_bold_border, |
| 105 | + ) |
69 | 106 | it += 1 |
70 | 107 |
|
71 | 108 | it = 1 |
72 | 109 | for task_name in list(set(set_of_task_name)): |
73 | | - worksheet.write(it, 0, task_name, workbook.add_format({'bold': True, 'right': 2})) |
| 110 | + worksheet.write( |
| 111 | + it, 0, task_name, workbook.add_format({"bold": True, "right": 2}) |
| 112 | + ) |
74 | 113 | it += 1 |
75 | 114 |
|
76 | 115 | it_i = 1 |
77 | 116 | it_j = 1 |
78 | | - right_border = workbook.add_format({'right': 2}) |
| 117 | + right_border = workbook.add_format({"right": 2}) |
79 | 118 | for task_name in list(set(set_of_task_name)): |
80 | 119 | for type_of_task in list_of_type_of_tasks: |
81 | 120 | if task_name not in result_tables[table_name].keys(): |
|
104 | 143 | it_j += 1 |
105 | 144 | workbook.close() |
106 | 145 | # Dump CSV for performance times |
107 | | - csv_file = os.path.join(xlsx_path, table_name + '_perf_table.csv') |
108 | | - with open(csv_file, 'w', newline='') as csvfile: |
| 146 | + csv_file = os.path.join(xlsx_path, table_name + "_perf_table.csv") |
| 147 | + with open(csv_file, "w", newline="") as csvfile: |
109 | 148 | writer = csv.writer(csvfile) |
110 | 149 | # Write header: Task, SEQ, OMP, TBB, STL, ALL |
111 | | - writer.writerow(['Task', 'SEQ', 'OMP', 'TBB', 'STL', 'ALL']) |
| 150 | + writer.writerow(["Task", "SEQ", "OMP", "TBB", "STL", "ALL"]) |
112 | 151 | for task_name in sorted(result_tables[table_name].keys()): |
113 | | - seq_time = result_tables[table_name][task_name]['seq'] |
| 152 | + seq_time = result_tables[table_name][task_name]["seq"] |
114 | 153 | row = [ |
115 | 154 | task_name, |
116 | | - 1.0 if seq_time != 0 else '?', |
117 | | - (result_tables[table_name][task_name]['omp'] / seq_time) if seq_time != 0 else '?', |
118 | | - (result_tables[table_name][task_name]['tbb'] / seq_time) if seq_time != 0 else '?', |
119 | | - (result_tables[table_name][task_name]['stl'] / seq_time) if seq_time != 0 else '?', |
120 | | - (result_tables[table_name][task_name]['all'] / seq_time) if seq_time != 0 else '?', |
| 155 | + 1.0 if seq_time != 0 else "?", |
| 156 | + (result_tables[table_name][task_name]["omp"] / seq_time) |
| 157 | + if seq_time != 0 |
| 158 | + else "?", |
| 159 | + (result_tables[table_name][task_name]["tbb"] / seq_time) |
| 160 | + if seq_time != 0 |
| 161 | + else "?", |
| 162 | + (result_tables[table_name][task_name]["stl"] / seq_time) |
| 163 | + if seq_time != 0 |
| 164 | + else "?", |
| 165 | + (result_tables[table_name][task_name]["all"] / seq_time) |
| 166 | + if seq_time != 0 |
| 167 | + else "?", |
121 | 168 | ] |
122 | 169 | writer.writerow(row) |
0 commit comments