Skip to content

Commit

Permalink
Fix TOTAL row and % column output in diff mode
Browse files Browse the repository at this point in the history
Fixes #361 and #335.

Before:
    FILE SIZE        VM SIZE
 --------------  --------------
  +203% +1.46Ki  [ = ]       0    [Unmapped]
  +100%     +48  +100%     +48    .rodata
  +100%      -8  +100%      -8    .ARM.exidx
   +50%      -8   +50%      -8    .fini
  +100%     -12  +100%     -12    .ARM.extab
   +99% -5.48Ki   +99% -5.48Ki    .text
  +100% +1.72Mi  +100% +1.72Mi    TOTAL

After:
    FILE SIZE        VM SIZE
 --------------  --------------
  +103% +1.46Ki  [ = ]       0    [Unmapped]
  +0.0%     +48  +0.0%     +48    .rodata
  -0.0%      -8  -0.0%      -8    .ARM.exidx
 -50.0%      -8 -50.0%      -8    .fini
  -0.0%     -12  -0.0%     -12    .ARM.extab
  -0.5% -5.48Ki  -0.5% -5.48Ki    .text
  -0.2% -4.00Ki  -0.3% -5.46Ki    TOTAL
  • Loading branch information
pepsiman authored and Malcolm Parsons committed Sep 24, 2023
1 parent 3925908 commit 30aeb0b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/bloaty.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@ class Rollup {
row->filtered_size.file = filtered_file_total_;
row->vmpercent = 100;
row->filepercent = 100;
if (base) {
row->size.vm -= base->vm_total_;
row->size.file -= base->file_total_;
}
output->diff_mode_ = true;
CreateRows(row, base, options, true);
}
Expand Down Expand Up @@ -384,7 +388,7 @@ class Rollup {
return -INFINITY;
}
} else {
return static_cast<double>(part) / static_cast<double>(whole) * 100;
return static_cast<double>(part - whole) / static_cast<double>(whole) * 100;
}
}

Expand Down

0 comments on commit 30aeb0b

Please sign in to comment.