@@ -494,6 +494,22 @@ def calculate_object_stats(stats):
494
494
rows .append ((label , value , ratio ))
495
495
return rows
496
496
497
+ def calculate_gc_stats (stats ):
498
+ gc_stats = []
499
+ for key , value in stats .items ():
500
+ if not key .startswith ("GC" ):
501
+ continue
502
+ n , _ , rest = key [3 :].partition ("]" )
503
+ name = rest .strip ()
504
+ gen_n = int (n )
505
+ while len (gc_stats ) <= gen_n :
506
+ gc_stats .append ({})
507
+ gc_stats [gen_n ][name ] = value
508
+ return [
509
+ (i , gen ["collections" ], gen ["objects collected" ], gen ["object visits" ])
510
+ for (i , gen ) in enumerate (gc_stats )
511
+ ]
512
+
497
513
def emit_object_stats (stats ):
498
514
with Section ("Object stats" , summary = "allocations, frees and dict materializatons" ):
499
515
rows = calculate_object_stats (stats )
@@ -505,6 +521,22 @@ def emit_comparative_object_stats(base_stats, head_stats):
505
521
head_rows = calculate_object_stats (head_stats )
506
522
emit_table (("" , "Base Count:" , "Base Ratio:" , "Head Count:" , "Head Ratio:" ), join_rows (base_rows , head_rows ))
507
523
524
+ def emit_gc_stats (stats ):
525
+ with Section ("GC stats" , summary = "GC collections and effectiveness" ):
526
+ rows = calculate_gc_stats (stats )
527
+ emit_table (("Generation:" , "Collections:" , "Objects collected:" , "Object visits:" ), rows )
528
+
529
+ def emit_comparative_gc_stats (base_stats , head_stats ):
530
+ with Section ("GC stats" , summary = "GC collections and effectiveness" ):
531
+ base_rows = calculate_gc_stats (base_stats )
532
+ head_rows = calculate_gc_stats (head_stats )
533
+ emit_table (
534
+ ("Generation:" ,
535
+ "Base collections:" , "Head collections:" ,
536
+ "Base objects collected:" , "Head objects collected:" ,
537
+ "Base object visits:" , "Head object visits:" ),
538
+ join_rows (base_rows , head_rows ))
539
+
508
540
def get_total (opcode_stats ):
509
541
total = 0
510
542
for opcode_stat in opcode_stats :
@@ -574,6 +606,7 @@ def output_single_stats(stats):
574
606
emit_specialization_overview (opcode_stats , total )
575
607
emit_call_stats (stats )
576
608
emit_object_stats (stats )
609
+ emit_gc_stats (stats )
577
610
with Section ("Meta stats" , summary = "Meta statistics" ):
578
611
emit_table (("" , "Count:" ), [('Number of data files' , stats ['__nfiles__' ])])
579
612
@@ -596,6 +629,7 @@ def output_comparative_stats(base_stats, head_stats):
596
629
)
597
630
emit_comparative_call_stats (base_stats , head_stats )
598
631
emit_comparative_object_stats (base_stats , head_stats )
632
+ emit_comparative_gc_stats (base_stats , head_stats )
599
633
600
634
def output_stats (inputs , json_output = None ):
601
635
if len (inputs ) == 1 :
0 commit comments