btrfs-progs: tree-stats: print average fanout for each level

Calculate average fanout between levels:

        Levels: 4
        Total nodes: 289048
                On level 0:   288054
                On level 1:      989  (avg fanout 291)
                On level 2:        4  (avg fanout 247)
                On level 3:        1  (avg fanout 4)

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2020-07-27 15:39:19 +02:00
parent 1c557766d2
commit 7ee65c6b22
1 changed files with 11 additions and 2 deletions

View File

@ -407,8 +407,17 @@ out_print:
} }
printf("\tLevels: %d\n", level + 1); printf("\tLevels: %d\n", level + 1);
printf("\tTotal nodes: %llu\n", stat.total_nodes); printf("\tTotal nodes: %llu\n", stat.total_nodes);
for (i = 0; i < level + 1; i++) for (i = 0; i < level + 1; i++) {
printf("\t\tOn level %d: %llu\n", i, stat.node_counts[i]); printf("\t\tOn level %d: %8llu", i, stat.node_counts[i]);
if (i > 0) {
u64 fanout;
fanout = stat.node_counts[i - 1];
fanout /= stat.node_counts[i];
printf(" (avg fanout %llu)", fanout);
}
printf("\n");
}
out: out:
while ((n = rb_first(&stat.seek_root)) != NULL) { while ((n = rb_first(&stat.seek_root)) != NULL) {
struct seek *seek = rb_entry(n, struct seek, n); struct seek *seek = rb_entry(n, struct seek, n);