@@ -202,6 +202,29 @@ def format_table(base_label, changed_label, results):
202202 output .insert (2 , "" .join (header_sep_line ))
203203 return "\n " .join (output )
204204
205+ def _format_github_row (items ):
206+ return "| " + " | " .join (items ) + " |"
207+
208+ def format_github_table (base_label , changed_label , results ):
209+ columns = ("Benchmark" , base_label , changed_label , "Change" , "Significance" )
210+ output = [_format_github_row (columns ), "| --- " * len (columns ) + "|" ]
211+
212+ for (bench_name , result ) in results :
213+ format_value = result .base .format_value
214+ avg_base = result .base .mean ()
215+ avg_changed = result .changed .mean ()
216+ delta_avg = quantity_delta (result .base , result .changed )
217+ msg = significant_msg (result .base , result .changed )
218+ rows = (bench_name ,
219+ # Limit the precision for conciseness in the table.
220+ format_value (avg_base ),
221+ format_value (avg_changed ),
222+ delta_avg ,
223+ msg )
224+ output .append (_format_github_row (rows ))
225+
226+ return "\n " .join (output )
227+
205228
206229class BenchmarkResult (object ):
207230 """An object representing data from a succesful benchmark run."""
@@ -355,6 +378,9 @@ def compare_results(options):
355378 elif options .output_style == "table" :
356379 if shown :
357380 print (format_table (base_label , changed_label , shown ))
381+ elif options .output_style == "table_github" :
382+ if shown :
383+ print (format_github_table (base_label , changed_label , shown ))
358384 else :
359385 raise ValueError ("Invalid output_style: %r" % options .output_style )
360386
0 commit comments