@@ -30,7 +30,6 @@ def load_results(
3030 """Load all benchmark results from the directory"""
3131 results = []
3232 for filename in glob .glob (f"{ results_dir } /blacksheep_perf_*.json" ):
33- print (filename )
3433 with open (filename , "r" ) as f :
3534 data = json .load (f )
3635 if not _match_filter (data , python_filter , platform_filter ):
@@ -189,7 +188,7 @@ def _add_ms_chart(workbook, df, worksheet, max_row):
189188
190189 # Add a chart title and some axis labels.
191190 chart .set_title ({"name" : "Performance comparison (lower is better)" })
192- chart .set_x_axis ({"name" : "commit " })
191+ chart .set_x_axis ({"name" : "" })
193192 chart .set_y_axis ({"name" : "avg ms" })
194193
195194 # Set an Excel chart style. Colors with white outline and shadow.
@@ -240,6 +239,18 @@ def _add_charts(workbook, df, worksheet, max_row):
240239 _add_mem_chart (workbook , df , worksheet , max_row )
241240
242241
242+ def _set_number_format (workbook , worksheet , df ):
243+ # Set number format for columns with "avg_ms" or "peak_mb" in their header
244+ number_format = workbook .add_format (
245+ {"num_format" : "0.00000000" , "align" : "left" }
246+ ) # 8 decimal points
247+ for col in df .columns :
248+ if "avg_ms" in col or "peak_mb" in col :
249+ col_index = df .columns .get_loc (col ) # Get the column index
250+ col_letter = chr (65 + col_index ) # Convert column index to Excel letter
251+ worksheet .set_column (f"{ col_letter } :{ col_letter } " , None , number_format )
252+
253+
243254def write_excel (df , output_file_name : str ):
244255 if not output_file_name .endswith (".xlsx" ):
245256 output_file_name = output_file_name + ".xlsx"
@@ -256,10 +267,19 @@ def write_excel(df, output_file_name: str):
256267 # Get the xlsxwriter workbook and worksheet objects.
257268 workbook = writer .book
258269 worksheet = writer .sheets ["results" ]
270+ _set_number_format (workbook , worksheet , df )
259271
260272 # Get the dimensions of the dataframe.
261- (max_row , _ ) = df .shape
273+ (max_row , max_col ) = df .shape
262274
275+ # Add a table to the worksheet
276+ worksheet .add_table (
277+ f"A1:{ chr (65 + max_col - 1 )} { max_row + 1 } " ,
278+ {
279+ "columns" : [{"header" : col } for col in df .columns ],
280+ "style" : "Table Style Medium 9" ,
281+ },
282+ )
263283 # Configure the first series.
264284 # Plot time metrics
265285
@@ -309,7 +329,7 @@ def write_excel(df, output_file_name: str):
309329 results = load_results (args .results_dir , args .python , args .platform )
310330 if not results :
311331 print (f"No benchmark results found in { args .results_dir } " )
312- exit (1 )
332+ exit (0 )
313333
314334 df = create_comparison_table (results )
315335 df = _aggregate (df , args .group_by )
0 commit comments