@@ -49,6 +49,10 @@ def format_geometric_mean(norm_means):
49
49
return format_normalized_mean (geo_mean )
50
50
51
51
52
+ def get_tags_for_result (result ):
53
+ return result .ref .benchmark .get_metadata ().get ("tags" , [])
54
+
55
+
52
56
class CompareResult (object ):
53
57
def __init__ (self , ref , changed , min_speed = None ):
54
58
# CompareData object
@@ -242,6 +246,12 @@ def __init__(self, benchmarks, args):
242
246
243
247
self .show_name = (len (grouped_by_name ) > 1 )
244
248
249
+ self .tags = set ()
250
+ for results in self .all_results :
251
+ for result in results :
252
+ self .tags .update (get_tags_for_result (result ))
253
+ self .tags = sorted (list (self .tags ))
254
+
245
255
def compare_benchmarks (self , name , benchmarks ):
246
256
min_speed = self .min_speed
247
257
@@ -258,11 +268,11 @@ def compare_benchmarks(self, name, benchmarks):
258
268
return results
259
269
260
270
@staticmethod
261
- def display_not_signiticant (not_significant ):
271
+ def display_not_significant (not_significant ):
262
272
print ("Benchmark hidden because not significant (%s): %s"
263
273
% (len (not_significant ), ', ' .join (not_significant )))
264
274
265
- def compare_suites_table (self ):
275
+ def compare_suites_table (self , all_results ):
266
276
if self .group_by_speed :
267
277
def sort_key (results ):
268
278
result = results [0 ]
@@ -280,7 +290,7 @@ def sort_key(results):
280
290
281
291
rows = []
282
292
not_significant = []
283
- for results in self . all_results :
293
+ for results in all_results :
284
294
row = [results .name ]
285
295
286
296
ref_bench = results [0 ].ref .benchmark
@@ -324,14 +334,14 @@ def sort_key(results):
324
334
if not_significant :
325
335
if rows :
326
336
print ()
327
- self .display_not_signiticant (not_significant )
337
+ self .display_not_significant (not_significant )
328
338
329
- def compare_suites_by_speed (self ):
339
+ def compare_suites_by_speed (self , all_results ):
330
340
not_significant = []
331
341
slower = []
332
342
faster = []
333
343
same = []
334
- for results in self . all_results :
344
+ for results in all_results :
335
345
result = results [0 ]
336
346
if not result .significant :
337
347
not_significant .append (results .name )
@@ -372,14 +382,14 @@ def sort_key(item):
372
382
if not self .quiet and not_significant :
373
383
if empty_line :
374
384
print ()
375
- self .display_not_signiticant (not_significant )
385
+ self .display_not_significant (not_significant )
376
386
377
- def compare_suites_list (self ):
387
+ def compare_suites_list (self , all_results ):
378
388
not_significant = []
379
389
empty_line = False
380
390
last_index = (len (self .all_results ) - 1 )
381
391
382
- for index , results in enumerate (self . all_results ):
392
+ for index , results in enumerate (all_results ):
383
393
significant = any (result .significant for result in results )
384
394
lines = []
385
395
for result in results :
@@ -406,7 +416,7 @@ def compare_suites_list(self):
406
416
if not self .quiet and not_significant :
407
417
if empty_line :
408
418
print ()
409
- self .display_not_signiticant (not_significant )
419
+ self .display_not_significant (not_significant )
410
420
411
421
def list_ignored (self ):
412
422
for suite , hidden in self .benchmarks .group_by_name_ignored ():
@@ -416,9 +426,7 @@ def list_ignored(self):
416
426
print ("Ignored benchmarks (%s) of %s: %s"
417
427
% (len (hidden ), suite .filename , ', ' .join (sorted (hidden_names ))))
418
428
419
- def compare_geometric_mean (self ):
420
- all_results = self .all_results
421
-
429
+ def compare_geometric_mean (self , all_results ):
422
430
# use a list since two filenames can be identical,
423
431
# even if results are different
424
432
all_norm_means = []
@@ -443,16 +451,29 @@ def compare_geometric_mean(self):
443
451
geo_mean = format_geometric_mean (all_norm_means [0 ][1 ])
444
452
print (f'Geometric mean: { geo_mean } ' )
445
453
446
- def compare (self ):
454
+ def compare_suites (self , results ):
447
455
if self .table :
448
- self .compare_suites_table ()
456
+ self .compare_suites_table (results )
449
457
else :
450
458
if self .group_by_speed :
451
- self .compare_suites_by_speed ()
459
+ self .compare_suites_by_speed (results )
452
460
else :
453
- self .compare_suites_list ()
461
+ self .compare_suites_list (results )
454
462
455
- self .compare_geometric_mean ()
463
+ self .compare_geometric_mean (results )
464
+
465
+ def compare (self ):
466
+ if len (self .tags ):
467
+ for tag in self .tags :
468
+ display_title (f"Benchmarks with tag '{ tag } ':" )
469
+ all_results = [
470
+ results for results in self .all_results
471
+ if tag is None or tag in get_tags_for_result (results [0 ])
472
+ ]
473
+ self .compare_suites (all_results )
474
+ print ()
475
+ display_title (f"All benchmarks:" )
476
+ self .compare_suites (self .all_results )
456
477
457
478
if not self .quiet :
458
479
self .list_ignored ()
0 commit comments