3535
3636import numpy as np
3737import matplotlib .pyplot as plt
38+ import matplotlib .ticker as ticker
3839import pandas as pd
3940from pandas .core .frame import DataFrame
4041import re
@@ -193,11 +194,11 @@ def tuple_of_secondary_keys(params: BMParams) -> Tuple:
193194 return tuple (secondaryKeys )
194195
195196
196- def plot_all_results (params : BMParams , resultSets : ResultSets , path , include_benchmarks : str , exclude_benchmarks : str , label : str ) -> None :
197+ def plot_all_results (params : BMParams , xaxisparam : Dict , result_sets : ResultSets , path , include_benchmarks : str , exclude_benchmarks : str , label : str , value_size_title : str , system_info : str ) -> None :
197198 indexKeys = tuple_of_secondary_keys (params )
198- for indexTuple , resultSet in resultSets .items ():
199- plot_result_set (indexKeys , indexTuple , resultSet ,
200- path , include_benchmarks , exclude_benchmarks , label )
199+ for indexTuple , resultSet in result_sets .items ():
200+ plot_result_set (xaxisparam , indexKeys , indexTuple , resultSet ,
201+ path , include_benchmarks , exclude_benchmarks , label , value_size_title , system_info )
201202
202203
203204def plot_result_axis_errorbars (ax , resultSet : ResultSet ) -> None :
@@ -256,7 +257,7 @@ def plot_result_axis_bars(ax, resultSet: ResultSet) -> None:
256257 bmIndex = bmIndex + 1
257258
258259
259- def plot_result_set (indexKeys : Tuple , indexTuple : Tuple , resultSet : ResultSet , path : pathlib .Path , include_benchmarks : str , exclude_benchmarks : str , label : str ):
260+ def plot_result_set (xaxisparam : Dict , indexKeys : Tuple , indexTuple : Tuple , resultSet : ResultSet , path : pathlib .Path , include_benchmarks : str , exclude_benchmarks : str , label : str , value_size_title : str , system_info : str ):
260261 # Determine how many colors we need
261262 num_benchmarks = len (resultSet )
262263
@@ -273,18 +274,24 @@ def plot_result_set(indexKeys: Tuple, indexTuple: Tuple, resultSet: ResultSet, p
273274
274275 plot_result_axis_bars (ax , resultSet )
275276
276- plt .suptitle ("x86_64 - Xeon E5-1650 v3 @ 3.50GHz - 128GB ECC RAM - Ubuntu 24.04.3 LTS - Kernel: 6.14.0-36-generic" )
277- plt .title (
278- f'{ str (indexKeys )} ={ str (indexTuple )} include={ include_benchmarks } exclude={ exclude_benchmarks } ' )
279- plt .xlabel ("# Operations" )
277+ # Ensure more marks on the x-axis for log scale
278+ ax .xaxis .set_major_locator (ticker .LogLocator (base = 10.0 , numticks = 15 ))
279+ ax .xaxis .set_minor_locator (ticker .LogLocator (base = 10.0 , subs = 'auto' , numticks = 15 ))
280+ ax .xaxis .set_major_formatter (ticker .ScalarFormatter ())
281+ ax .xaxis .set_minor_formatter (ticker .NullFormatter ())
282+
283+ plt .suptitle (system_info )
284+ title = f'{ str (indexKeys )} ={ str (indexTuple )} include={ include_benchmarks } exclude={ exclude_benchmarks } Value Size="{ value_size_title } "'
285+ plt .title (title )
286+ plt .xlabel (extract_parameter_name (xaxisparam ))
280287 plt .ylabel ("t (ns)" )
281288 plt .legend (loc = 'upper left' , bbox_to_anchor = (1 , 1 ))
282289 plt .grid (visible = 'True' , which = 'both' )
283290
284291 name = f'fig_{ "_" .join ([str (t ) for t in indexTuple ])} _{ label } .png'
285292
286293 if path .is_file ():
287- path = path .parent ()
294+ path = path .parent
288295 fig .savefig (path .joinpath (name ), bbox_inches = 'tight' )
289296
290297
@@ -322,7 +329,7 @@ def filter_for_benchmarks(dataframe: DataFrame, include_benchmarks, exclude_benc
322329
323330def filter_for_range (dataframe : DataFrame , xaxisparam : Dict ) -> DataFrame :
324331
325- param_name = required ( 'name' , xaxisparam )
332+ param_name = extract_parameter_name ( xaxisparam )
326333 xmin = optional ('min' , xaxisparam , lambda x : int (x ))
327334 xmax = optional ('max' , xaxisparam , lambda x : int (x ))
328335 if xmax is None and xmin is None :
@@ -340,6 +347,14 @@ def filter_for_range(dataframe: DataFrame, xaxisparam: Dict) -> DataFrame:
340347 lambda x : int (x ) >= xmin and int (x ) <= xmax )]
341348
342349
350+ def extract_parameter_name (xaxisparam ):
351+ return required ('name' , xaxisparam )
352+
353+
354+ def default_if_none (optional_string , default_value : str ) -> str :
355+ return default_value if optional_string is None else optional_string
356+
357+
343358def process_some_plots (path : pathlib .Path , plot : Dict ) -> None :
344359
345360 xaxisparam = required ('xaxisparam' , plot )
@@ -348,6 +363,26 @@ def process_some_plots(path: pathlib.Path, plot: Dict) -> None:
348363 include_benchmarks = optional ('include_patterns' , plot )
349364 exclude_benchmarks = optional ('exclude_patterns' , plot )
350365 label = required ('label' , plot )
366+ value_size_title = default_if_none (optional ('valueSizeTitle' , plot ), "All" )
367+
368+ # Check for system_info.json in the path
369+ system_info = None
370+ system_info_file = None
371+ if path .is_dir ():
372+ system_info_file = path .joinpath ('system_info.json' )
373+ if path .is_file ():
374+ system_info_file = path .parent .joinpath ('system_info.json' )
375+
376+ if system_info_file and system_info_file .exists ():
377+ try :
378+ with system_info_file .open (mode = 'r' , encoding = 'UTF-8' ) as f :
379+ info_json = json .load (f )
380+ system_info = info_json .get ('system_info' )
381+ except Exception :
382+ pass
383+
384+ if system_info is None :
385+ system_info = "System Info unavailable"
351386
352387 dataframe = normalize_data_frame_from_path (path )
353388 if len (dataframe ) == 0 :
@@ -368,8 +403,8 @@ def process_some_plots(path: pathlib.Path, plot: Dict) -> None:
368403 params : BMParams = split_params (
369404 extract_params (dataframe ), primary_param_name )
370405 resultSets = extract_results_per_param (dataframe , params )
371- plot_all_results (params , resultSets , path ,
372- include_benchmarks , exclude_benchmarks , label )
406+ plot_all_results (params , xaxisparam , resultSets , path ,
407+ include_benchmarks , exclude_benchmarks , label , value_size_title , system_info )
373408
374409
375410def process_benchmarks (config : Dict ) -> None :
0 commit comments