diff options
author | brandonvu12 <bvu106038@gmail.com> | 2022-07-12 21:58:21 +0000 |
---|---|---|
committer | brandonvu12 <bvu106038@gmail.com> | 2022-07-12 21:58:21 +0000 |
commit | 5ab4f4e61316e68eb0f6e6b06c5d5388691bbd7a (patch) | |
tree | a458bc2e3e56698ecf7ad94c3fd2dfad70fa2a31 | |
parent | 7d5c8fa6f141c3301b43669f287c912064f464dd (diff) | |
download | bloaty-5ab4f4e61316e68eb0f6e6b06c5d5388691bbd7a.tar.gz |
Remove new_size variable and derive values by adding diff size to base size.
-rw-r--r-- | src/bloaty.cc | 29 | ||||
-rw-r--r-- | src/bloaty.h | 5 |
2 files changed, 16 insertions, 18 deletions
diff --git a/src/bloaty.cc b/src/bloaty.cc index f49fb6e..a9f02e5 100644 --- a/src/bloaty.cc +++ b/src/bloaty.cc @@ -431,21 +431,13 @@ void Rollup::CreateRows(RollupRow* row, const Rollup* base, child_row.size.vm = vm_total; child_row.size.file = file_total; - // Preserve the old and new sizes for this label in the RollupRow output. + // Preserve the old size for this label in the RollupRow output. // If there is a diff base, the old sizes come from the size of the label - // in that base. Otherwise, the old size is the same as the new (current) - // size. + // in that base. Otherwise, the old size stays 0. if (base_child) { child_row.old_size.vm = base_child->vm_total_; child_row.old_size.file = base_child->file_total_; - child_row.new_size.vm = value.second->vm_total_; - child_row.new_size.file = value.second->file_total_; - } else { - child_row.old_size.vm = child_row.size.vm; - child_row.old_size.file = child_row.size.file; - child_row.new_size.vm = child_row.size.vm; - child_row.new_size.file = child_row.size.file; - } + } } } @@ -847,10 +839,19 @@ void RollupOutput::PrintRowToCSV(const RollupRow& row, parent_labels.push_back(std::to_string(row.size.vm)); parent_labels.push_back(std::to_string(row.size.file)); + + // If in diff where both old size are 0, get new size by adding diff size to old size. parent_labels.push_back(std::to_string(row.old_size.vm)); - parent_labels.push_back(std::to_string(row.old_size.file)); - parent_labels.push_back(std::to_string(row.new_size.vm)); - parent_labels.push_back(std::to_string(row.new_size.file)); + parent_labels.push_back(std::to_string(row.old_size.file)); + if (row.old_size.vm != 0 && row.old_size.file != 0){ + parent_labels.push_back(std::to_string(row.old_size.vm + (row.size.vm))); + parent_labels.push_back(std::to_string(row.old_size.file + (row.size.file))); + } else { + parent_labels.push_back(std::to_string(0)); + parent_labels.push_back(std::to_string(0)); + } + + std::string sep = tabs ? "\t" : ","; *out << absl::StrJoin(parent_labels, sep) << "\n"; diff --git a/src/bloaty.h b/src/bloaty.h index 68abb70..f3a6c33 100644 --- a/src/bloaty.h +++ b/src/bloaty.h @@ -354,11 +354,8 @@ struct RollupRow { double vmpercent; double filepercent; - // The size of this row in a diff base. Same as `size` for non-diff. + // The size of the base in a diff mode. Otherwise stay 0. DomainSizes old_size = {0, 0}; - // The current size of this row (this is not the same as `size` in the case - // of a diff -- `size` is the delta). - DomainSizes new_size = {0, 0}; std::vector<RollupRow> sorted_children; |