@@ -36,6 +36,17 @@ def create_parser():
36
36
parser = ArgumentParser (
37
37
description = 'versatile benchmark output compare tool' )
38
38
39
+ parser .add_argument (
40
+ '-a' ,
41
+ '--display_aggregates_only' ,
42
+ dest = 'display_aggregates_only' ,
43
+ action = "store_true" ,
44
+ help = "If there are repetitions, by default, we display everything - the"
45
+ " actual runs, and the aggregates computed. Sometimes, it is "
46
+ "desirable to only view the aggregates. E.g. when there are a lot "
47
+ "of repetitions. Do note that only the display is affected. "
48
+ "Internally, all the actual runs are still used, e.g. for U test." )
49
+
39
50
utest = parser .add_argument_group ()
40
51
utest .add_argument (
41
52
'--no-utest' ,
@@ -200,6 +211,9 @@ def main():
200
211
201
212
check_inputs (test_baseline , test_contender , benchmark_options )
202
213
214
+ if args .display_aggregates_only :
215
+ benchmark_options += ['--benchmark_display_aggregates_only=true' ]
216
+
203
217
options_baseline = []
204
218
options_contender = []
205
219
@@ -223,7 +237,8 @@ def main():
223
237
224
238
# Diff and output
225
239
output_lines = gbench .report .generate_difference_report (
226
- json1 , json2 , args .utest , args .utest_alpha )
240
+ json1 , json2 , args .display_aggregates_only ,
241
+ args .utest , args .utest_alpha )
227
242
print (description )
228
243
for ln in output_lines :
229
244
print (ln )
@@ -246,6 +261,7 @@ def setUp(self):
246
261
def test_benchmarks_basic (self ):
247
262
parsed = self .parser .parse_args (
248
263
['benchmarks' , self .testInput0 , self .testInput1 ])
264
+ self .assertFalse (parsed .display_aggregates_only )
249
265
self .assertTrue (parsed .utest )
250
266
self .assertEqual (parsed .mode , 'benchmarks' )
251
267
self .assertEqual (parsed .test_baseline [0 ].name , self .testInput0 )
@@ -255,16 +271,28 @@ def test_benchmarks_basic(self):
255
271
def test_benchmarks_basic_without_utest (self ):
256
272
parsed = self .parser .parse_args (
257
273
['--no-utest' , 'benchmarks' , self .testInput0 , self .testInput1 ])
274
+ self .assertFalse (parsed .display_aggregates_only )
258
275
self .assertFalse (parsed .utest )
259
276
self .assertEqual (parsed .utest_alpha , 0.05 )
260
277
self .assertEqual (parsed .mode , 'benchmarks' )
261
278
self .assertEqual (parsed .test_baseline [0 ].name , self .testInput0 )
262
279
self .assertEqual (parsed .test_contender [0 ].name , self .testInput1 )
263
280
self .assertFalse (parsed .benchmark_options )
264
281
282
+ def test_benchmarks_basic_display_aggregates_only (self ):
283
+ parsed = self .parser .parse_args (
284
+ ['-a' , 'benchmarks' , self .testInput0 , self .testInput1 ])
285
+ self .assertTrue (parsed .display_aggregates_only )
286
+ self .assertTrue (parsed .utest )
287
+ self .assertEqual (parsed .mode , 'benchmarks' )
288
+ self .assertEqual (parsed .test_baseline [0 ].name , self .testInput0 )
289
+ self .assertEqual (parsed .test_contender [0 ].name , self .testInput1 )
290
+ self .assertFalse (parsed .benchmark_options )
291
+
265
292
def test_benchmarks_basic_with_utest_alpha (self ):
266
293
parsed = self .parser .parse_args (
267
294
['--alpha=0.314' , 'benchmarks' , self .testInput0 , self .testInput1 ])
295
+ self .assertFalse (parsed .display_aggregates_only )
268
296
self .assertTrue (parsed .utest )
269
297
self .assertEqual (parsed .utest_alpha , 0.314 )
270
298
self .assertEqual (parsed .mode , 'benchmarks' )
@@ -275,6 +303,7 @@ def test_benchmarks_basic_with_utest_alpha(self):
275
303
def test_benchmarks_basic_without_utest_with_utest_alpha (self ):
276
304
parsed = self .parser .parse_args (
277
305
['--no-utest' , '--alpha=0.314' , 'benchmarks' , self .testInput0 , self .testInput1 ])
306
+ self .assertFalse (parsed .display_aggregates_only )
278
307
self .assertFalse (parsed .utest )
279
308
self .assertEqual (parsed .utest_alpha , 0.314 )
280
309
self .assertEqual (parsed .mode , 'benchmarks' )
@@ -285,6 +314,7 @@ def test_benchmarks_basic_without_utest_with_utest_alpha(self):
285
314
def test_benchmarks_with_remainder (self ):
286
315
parsed = self .parser .parse_args (
287
316
['benchmarks' , self .testInput0 , self .testInput1 , 'd' ])
317
+ self .assertFalse (parsed .display_aggregates_only )
288
318
self .assertTrue (parsed .utest )
289
319
self .assertEqual (parsed .mode , 'benchmarks' )
290
320
self .assertEqual (parsed .test_baseline [0 ].name , self .testInput0 )
@@ -294,6 +324,7 @@ def test_benchmarks_with_remainder(self):
294
324
def test_benchmarks_with_remainder_after_doubleminus (self ):
295
325
parsed = self .parser .parse_args (
296
326
['benchmarks' , self .testInput0 , self .testInput1 , '--' , 'e' ])
327
+ self .assertFalse (parsed .display_aggregates_only )
297
328
self .assertTrue (parsed .utest )
298
329
self .assertEqual (parsed .mode , 'benchmarks' )
299
330
self .assertEqual (parsed .test_baseline [0 ].name , self .testInput0 )
@@ -303,6 +334,7 @@ def test_benchmarks_with_remainder_after_doubleminus(self):
303
334
def test_filters_basic (self ):
304
335
parsed = self .parser .parse_args (
305
336
['filters' , self .testInput0 , 'c' , 'd' ])
337
+ self .assertFalse (parsed .display_aggregates_only )
306
338
self .assertTrue (parsed .utest )
307
339
self .assertEqual (parsed .mode , 'filters' )
308
340
self .assertEqual (parsed .test [0 ].name , self .testInput0 )
@@ -313,6 +345,7 @@ def test_filters_basic(self):
313
345
def test_filters_with_remainder (self ):
314
346
parsed = self .parser .parse_args (
315
347
['filters' , self .testInput0 , 'c' , 'd' , 'e' ])
348
+ self .assertFalse (parsed .display_aggregates_only )
316
349
self .assertTrue (parsed .utest )
317
350
self .assertEqual (parsed .mode , 'filters' )
318
351
self .assertEqual (parsed .test [0 ].name , self .testInput0 )
@@ -323,6 +356,7 @@ def test_filters_with_remainder(self):
323
356
def test_filters_with_remainder_after_doubleminus (self ):
324
357
parsed = self .parser .parse_args (
325
358
['filters' , self .testInput0 , 'c' , 'd' , '--' , 'f' ])
359
+ self .assertFalse (parsed .display_aggregates_only )
326
360
self .assertTrue (parsed .utest )
327
361
self .assertEqual (parsed .mode , 'filters' )
328
362
self .assertEqual (parsed .test [0 ].name , self .testInput0 )
@@ -333,6 +367,7 @@ def test_filters_with_remainder_after_doubleminus(self):
333
367
def test_benchmarksfiltered_basic (self ):
334
368
parsed = self .parser .parse_args (
335
369
['benchmarksfiltered' , self .testInput0 , 'c' , self .testInput1 , 'e' ])
370
+ self .assertFalse (parsed .display_aggregates_only )
336
371
self .assertTrue (parsed .utest )
337
372
self .assertEqual (parsed .mode , 'benchmarksfiltered' )
338
373
self .assertEqual (parsed .test_baseline [0 ].name , self .testInput0 )
@@ -344,6 +379,7 @@ def test_benchmarksfiltered_basic(self):
344
379
def test_benchmarksfiltered_with_remainder (self ):
345
380
parsed = self .parser .parse_args (
346
381
['benchmarksfiltered' , self .testInput0 , 'c' , self .testInput1 , 'e' , 'f' ])
382
+ self .assertFalse (parsed .display_aggregates_only )
347
383
self .assertTrue (parsed .utest )
348
384
self .assertEqual (parsed .mode , 'benchmarksfiltered' )
349
385
self .assertEqual (parsed .test_baseline [0 ].name , self .testInput0 )
@@ -355,6 +391,7 @@ def test_benchmarksfiltered_with_remainder(self):
355
391
def test_benchmarksfiltered_with_remainder_after_doubleminus (self ):
356
392
parsed = self .parser .parse_args (
357
393
['benchmarksfiltered' , self .testInput0 , 'c' , self .testInput1 , 'e' , '--' , 'g' ])
394
+ self .assertFalse (parsed .display_aggregates_only )
358
395
self .assertTrue (parsed .utest )
359
396
self .assertEqual (parsed .mode , 'benchmarksfiltered' )
360
397
self .assertEqual (parsed .test_baseline [0 ].name , self .testInput0 )
@@ -365,7 +402,7 @@ def test_benchmarksfiltered_with_remainder_after_doubleminus(self):
365
402
366
403
367
404
if __name__ == '__main__' :
368
- # unittest.main()
405
+ #unittest.main()
369
406
main ()
370
407
371
408
# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4
0 commit comments