@@ -57,14 +57,21 @@ def build_result_map(report):
5757 return result_map
5858
5959
60+ def get_system_info (report ):
61+ """Extract system info dict from a report."""
62+ return report .get ('system' , {})
63+
64+
6065def compare (reports , paths ):
6166 impl_names = []
6267 result_maps = []
68+ system_infos = []
6369
6470 for i , report in enumerate (reports ):
6571 name = report .get ('openvx' , {}).get ('implementation' , os .path .basename (paths [i ]))
6672 impl_names .append (name )
6773 result_maps .append (build_result_map (report ))
74+ system_infos .append (get_system_info (report ))
6875
6976 # Collect all unique benchmark keys
7077 all_keys = set ()
@@ -73,21 +80,65 @@ def compare(reports, paths):
7380
7481 all_keys = sorted (all_keys )
7582
76- return impl_names , result_maps , all_keys
83+ return impl_names , result_maps , all_keys , system_infos
84+
7785
86+ def format_ram (ram_value ):
87+ """Format RAM value from report (may be gb float or bytes int)."""
88+ if isinstance (ram_value , (int ,)) and ram_value > 1e9 :
89+ return f'{ ram_value / (1024 ** 3 ):.1f} GB'
90+ return f'{ ram_value } GB'
7891
79- def write_markdown (impl_names , result_maps , all_keys , output_path ):
92+
93+ def write_markdown (impl_names , result_maps , all_keys , output_path , system_infos = None ):
8094 with open (output_path + '.md' , 'w' ) as f :
8195 f .write ('# OpenVX Benchmark Comparison\n \n ' )
8296
83- # System info table
97+ # Hardware / system info section
98+ if system_infos and len (system_infos ) >= 2 :
99+ hw_match = (system_infos [0 ].get ('cpu_model' ) == system_infos [1 ].get ('cpu_model' )
100+ and system_infos [0 ].get ('cpu_cores' ) == system_infos [1 ].get ('cpu_cores' ))
101+
102+ f .write ('## System Info\n \n ' )
103+ if hw_match :
104+ si = system_infos [0 ]
105+ f .write (f'| Property | Value |\n ' )
106+ f .write (f'|:---|:---|\n ' )
107+ f .write (f'| CPU | { si .get ("cpu_model" , "N/A" )} |\n ' )
108+ f .write (f'| Cores | { si .get ("cpu_cores" , "N/A" )} |\n ' )
109+ f .write (f'| RAM | { format_ram (si .get ("ram_gb" , si .get ("ram_bytes" , "N/A" )))} |\n ' )
110+ f .write (f'| OS | { si .get ("os_name" , "N/A" )} { si .get ("os_version" , "" )} |\n ' )
111+ f .write (f'\n > **Same hardware** — both benchmarks ran on identical hardware.\n \n ' )
112+ else :
113+ f .write (f'| Property |' )
114+ for name in impl_names :
115+ f .write (f' { name } |' )
116+ f .write ('\n |:---|' )
117+ for _ in impl_names :
118+ f .write (':---|' )
119+ f .write ('\n ' )
120+ for prop , key in [('CPU' , 'cpu_model' ), ('Cores' , 'cpu_cores' ),
121+ ('OS' , 'os_name' )]:
122+ f .write (f'| { prop } |' )
123+ for si in system_infos :
124+ f .write (f' { si .get (key , "N/A" )} |' )
125+ f .write ('\n ' )
126+ f .write (f'\n > **Warning:** Benchmarks ran on different hardware — results may not be directly comparable.\n \n ' )
127+
128+ # Implementation table
84129 f .write ('## Implementations\n \n ' )
85130 f .write ('| # | Implementation |\n ' )
86131 f .write ('|---|---|\n ' )
87132 for i , name in enumerate (impl_names ):
88133 f .write (f'| { i + 1 } | { name } |\n ' )
89134 f .write ('\n ' )
90135
136+ # Speedup label: first impl vs second
137+ if len (impl_names ) >= 2 :
138+ speedup_label = f'Speedup ({ impl_names [0 ]} vs { impl_names [1 ]} )'
139+ else :
140+ speedup_label = 'Speedup'
141+
91142 # Results table
92143 header = '| Benchmark | Mode | Resolution |'
93144 separator = '|:---|:---|:---|'
@@ -96,10 +147,11 @@ def write_markdown(impl_names, result_maps, all_keys, output_path):
96147 header += f' { short } (ms) | { short } (MP/s) |'
97148 separator += '---:|---:|'
98149
99- header += ' Speedup |'
150+ header += f ' Speedup |'
100151 separator += '---:|'
101152
102153 f .write ('## Results\n \n ' )
154+ f .write (f'> Speedup = how much faster **{ impl_names [0 ]} ** is compared to **{ impl_names [1 ]} ** (higher is better)\n \n ' )
103155 f .write (header + '\n ' )
104156 f .write (separator + '\n ' )
105157
@@ -120,9 +172,9 @@ def write_markdown(impl_names, result_maps, all_keys, output_path):
120172 row += ' N/A | N/A |'
121173 medians .append (None )
122174
123- # Speedup ( first vs second, if both available)
124- if len (medians ) >= 2 and medians [0 ] and medians [1 ] and medians [1 ] > 0 :
125- speedup = medians [0 ] / medians [1 ]
175+ # Speedup: baseline (second) / candidate ( first) — how much faster first is
176+ if len (medians ) >= 2 and medians [0 ] and medians [1 ] and medians [0 ] > 0 :
177+ speedup = medians [1 ] / medians [0 ]
126178 row += f' { speedup :.2f} x |'
127179 else :
128180 row += ' N/A |'
@@ -157,8 +209,8 @@ def write_csv(impl_names, result_maps, all_keys, output_path):
157209 row += ',,'
158210 medians .append (None )
159211
160- if len (medians ) >= 2 and medians [0 ] and medians [1 ] and medians [1 ] > 0 :
161- row += f',{ medians [0 ]/ medians [1 ]:.4f} '
212+ if len (medians ) >= 2 and medians [0 ] and medians [1 ] and medians [0 ] > 0 :
213+ row += f',{ medians [1 ]/ medians [0 ]:.4f} '
162214 else :
163215 row += ','
164216
@@ -184,9 +236,9 @@ def main():
184236 sys .exit (1 )
185237 reports .append (load_report (path ))
186238
187- impl_names , result_maps , all_keys = compare (reports , args .reports )
239+ impl_names , result_maps , all_keys , system_infos = compare (reports , args .reports )
188240
189- write_markdown (impl_names , result_maps , all_keys , args .output )
241+ write_markdown (impl_names , result_maps , all_keys , args .output , system_infos )
190242 write_csv (impl_names , result_maps , all_keys , args .output )
191243
192244 print (f'\n Compared { len (args .reports )} implementations across { len (all_keys )} benchmarks' )
0 commit comments