@@ -3308,6 +3308,26 @@ struct topo_walk_info {
3308
3308
struct author_date_slab author_date ;
3309
3309
};
3310
3310
3311
+ static int topo_walk_atexit_registered ;
3312
+ static unsigned int count_explore_walked ;
3313
+ static unsigned int count_indegree_walked ;
3314
+ static unsigned int count_topo_walked ;
3315
+
3316
+ static void trace2_topo_walk_statistics_atexit (void )
3317
+ {
3318
+ struct json_writer jw = JSON_WRITER_INIT ;
3319
+
3320
+ jw_object_begin (& jw , 0 );
3321
+ jw_object_intmax (& jw , "count_explore_walked" , count_explore_walked );
3322
+ jw_object_intmax (& jw , "count_indegree_walked" , count_indegree_walked );
3323
+ jw_object_intmax (& jw , "count_topo_walked" , count_topo_walked );
3324
+ jw_end (& jw );
3325
+
3326
+ trace2_data_json ("topo_walk" , the_repository , "statistics" , & jw );
3327
+
3328
+ jw_release (& jw );
3329
+ }
3330
+
3311
3331
static inline void test_flag_and_insert (struct prio_queue * q , struct commit * c , int flag )
3312
3332
{
3313
3333
if (c -> object .flags & flag )
@@ -3329,6 +3349,8 @@ static void explore_walk_step(struct rev_info *revs)
3329
3349
if (repo_parse_commit_gently (revs -> repo , c , 1 ) < 0 )
3330
3350
return ;
3331
3351
3352
+ count_explore_walked ++ ;
3353
+
3332
3354
if (revs -> sort_order == REV_SORT_BY_AUTHOR_DATE )
3333
3355
record_author_date (& info -> author_date , c );
3334
3356
@@ -3367,6 +3389,8 @@ static void indegree_walk_step(struct rev_info *revs)
3367
3389
if (repo_parse_commit_gently (revs -> repo , c , 1 ) < 0 )
3368
3390
return ;
3369
3391
3392
+ count_indegree_walked ++ ;
3393
+
3370
3394
explore_to_depth (revs , commit_graph_generation (c ));
3371
3395
3372
3396
for (p = c -> parents ; p ; p = p -> next ) {
@@ -3476,6 +3500,11 @@ static void init_topo_walk(struct rev_info *revs)
3476
3500
*/
3477
3501
if (revs -> sort_order == REV_SORT_IN_GRAPH_ORDER )
3478
3502
prio_queue_reverse (& info -> topo_queue );
3503
+
3504
+ if (trace2_is_enabled () && !topo_walk_atexit_registered ) {
3505
+ atexit (trace2_topo_walk_statistics_atexit );
3506
+ topo_walk_atexit_registered = 1 ;
3507
+ }
3479
3508
}
3480
3509
3481
3510
static struct commit * next_topo_commit (struct rev_info * revs )
@@ -3502,6 +3531,8 @@ static void expand_topo_walk(struct rev_info *revs, struct commit *commit)
3502
3531
oid_to_hex (& commit -> object .oid ));
3503
3532
}
3504
3533
3534
+ count_topo_walked ++ ;
3535
+
3505
3536
for (p = commit -> parents ; p ; p = p -> next ) {
3506
3537
struct commit * parent = p -> item ;
3507
3538
int * pi ;
0 commit comments