11# Copyright 2022 Intel Corp.
22# SPDX-FileCopyrightText: 2022 Intel Corporation
33#
4- # SPDX-License-Identifier: Apache 2.0
54# SPDX-License-Identifier: Apache-2.0
65
76"""The module generates reports for implementation summary and timing summary
109
1110import dataclasses
1211import logging
13- import pathlib
1412from typing import Final , Union
1513
1614import pandas as pd
@@ -82,8 +80,23 @@ def generate_header(conn: sqlalchemy.Engine, run_id: int):
8280 print ("==================================" )
8381
8482
85- def generate_legend (legends : pd .DataFrame ):
86- """prints legend section"""
83+ def generate_legend (conn : sqlalchemy .Engine , run_id : int ) -> list [str ]:
84+ """prints legend section and returns implementation list"""
85+ sql = (
86+ sqlalchemy .select (
87+ dm .Postfix .postfix ,
88+ dm .Postfix .description ,
89+ dm .Postfix .device ,
90+ )
91+ .order_by (dm .Postfix .postfix )
92+ .where (dm .Postfix .run_id == run_id )
93+ )
94+
95+ legends = pd .read_sql_query (
96+ sql = sql ,
97+ con = conn .connect (),
98+ )
99+
87100 formatters = {}
88101 for col in legends .select_dtypes ("object" ):
89102 len_max = legends [col ].str .len ().max ()
@@ -94,6 +107,8 @@ def generate_legend(legends: pd.DataFrame):
94107 print (legends .to_string (formatters = formatters ))
95108 print ("" )
96109
110+ return legends ["postfix" ].values .tolist ()
111+
97112
98113def generate_summary (data : pd .DataFrame ):
99114 """prints summary section"""
@@ -108,11 +123,6 @@ def generate_impl_summary_report(
108123 implementations : list [str ],
109124):
110125 """generate implementation summary report with status of each benchmark"""
111- legends = read_legends ()
112-
113- generate_header (conn , run_id )
114- generate_legend (legends )
115-
116126 columns = [
117127 func .max (dm .Result .input_size_human ).label ("input_size" ),
118128 dm .Result .benchmark ,
@@ -157,15 +167,8 @@ def generate_performance_report(
157167 conn : sqlalchemy .Engine ,
158168 run_id : int ,
159169 implementations : list [str ],
160- headless = False ,
161170):
162171 """generate performance report with median times for each benchmark"""
163- legends = read_legends ()
164-
165- if not headless :
166- generate_header (conn , run_id )
167- generate_legend (legends )
168-
169172 columns = [
170173 func .max (dm .Result .input_size_human ).label ("input_size" ),
171174 dm .Result .benchmark ,
@@ -222,18 +225,11 @@ def generate_comparison_report(
222225 run_id : int ,
223226 implementations : list [str ],
224227 comparison_pairs : list [tuple [str , str ]],
225- headless = False ,
226228):
227229 """generate comparison report with median times for each benchmark"""
228230 if len (comparison_pairs ) == 0 :
229231 return
230232
231- legends = read_legends ()
232-
233- if not headless :
234- generate_header (conn , run_id )
235- generate_legend (legends )
236-
237233 columns = [
238234 func .max (dm .Result .input_size_human ).label ("input_size" ),
239235 dm .Result .benchmark ,
@@ -331,14 +327,10 @@ def get_unexpected_failures(
331327def print_report (
332328 conn : sqlalchemy .Engine ,
333329 run_id : int ,
334- implementations : set [str ],
335330 comparison_pairs : list [tuple [str , str ]] = [],
336331):
337- if not implementations :
338- implementations = {impl .postfix for impl in cfg .GLOBAL .implementations }
339-
340- implementations = list (implementations )
341- implementations .sort ()
332+ generate_header (conn , run_id )
333+ implementations = generate_legend (conn , run_id )
342334
343335 generate_impl_summary_report (
344336 conn , run_id = run_id , implementations = implementations
@@ -348,15 +340,13 @@ def print_report(
348340 conn ,
349341 run_id = run_id ,
350342 implementations = implementations ,
351- headless = True ,
352343 )
353344
354345 generate_comparison_report (
355346 conn ,
356347 run_id = run_id ,
357348 implementations = implementations ,
358349 comparison_pairs = comparison_pairs ,
359- headless = True ,
360350 )
361351
362352 unexpected_failures = get_unexpected_failures (conn , run_id = run_id )
0 commit comments