@@ -220,11 +220,13 @@ class ReportFormatter(object):
220
220
`values()` into report table. Supported formats are: `markdown` (used for
221
221
displaying benchmark results on GitHub), `git` and `html`.
222
222
"""
223
- def __init__ (self , comparator , old_branch , new_branch , changes_only ):
223
+ def __init__ (self , comparator , old_branch , new_branch , changes_only ,
224
+ single_table = False ):
224
225
self .comparator = comparator
225
226
self .old_branch = old_branch
226
227
self .new_branch = new_branch
227
228
self .changes_only = changes_only
229
+ self .single_table = single_table
228
230
229
231
MARKDOWN_DETAIL = """
230
232
<details {3}>
@@ -266,6 +268,7 @@ def max_widths(maximum, widths):
266
268
267
269
def _formatted_text (self , ROW , HEADER_SEPARATOR , DETAIL ):
268
270
widths = self ._column_widths ()
271
+ self .header_printed = False
269
272
270
273
def justify_columns (contents ):
271
274
return tuple ([c .ljust (w ) for w , c in zip (widths , contents )])
@@ -285,12 +288,24 @@ def table(title, results, is_strong=False, is_open=False):
285
288
row (format_columns (result_comparison .values (), is_strong ))
286
289
for result_comparison in results
287
290
]
288
- return ('' if not rows else
289
- DETAIL .format (* [
290
- title , len (results ),
291
- (header (results [0 ].header ) + '' .join (rows )),
292
- ('open' if is_open else '' )
293
- ]))
291
+ if not rows :
292
+ return ''
293
+
294
+ if self .single_table :
295
+ t = ''
296
+ if not self .header_printed :
297
+ t += header (results [0 ].header )
298
+ self .header_printed = True
299
+ t += row (('**' + title + '**' , '' , '' , '' , '' ))
300
+ t += '' .join (rows )
301
+ return t
302
+
303
+ return DETAIL .format (
304
+ * [
305
+ title , len (results ),
306
+ (header (results [0 ].header ) + '' .join (rows )),
307
+ ('open' if is_open else '' )
308
+ ])
294
309
295
310
return '' .join ([
296
311
# FIXME print self.old_branch, self.new_branch
@@ -393,6 +408,10 @@ def parse_args(args):
393
408
parser .add_argument ('--output' , help = 'Output file name' )
394
409
parser .add_argument ('--changes-only' ,
395
410
help = 'Output only affected tests' , action = 'store_true' )
411
+ parser .add_argument (
412
+ '--single-table' ,
413
+ help = 'Combine data in a single table in git and markdown formats' ,
414
+ action = 'store_true' )
396
415
parser .add_argument ('--new-branch' ,
397
416
help = 'Name of the new branch' , default = 'NEW_MIN' )
398
417
parser .add_argument ('--old-branch' ,
@@ -408,7 +427,7 @@ def main():
408
427
comparator = TestComparator (args .old_file , args .new_file ,
409
428
args .delta_threshold )
410
429
formatter = ReportFormatter (comparator , args .old_branch , args .new_branch ,
411
- args .changes_only )
430
+ args .changes_only , args . single_table )
412
431
formats = {
413
432
'markdown' : formatter .markdown ,
414
433
'git' : formatter .git ,
0 commit comments