Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add summaries to monos sub-command output. #103

Merged
merged 1 commit into from
Aug 3, 2018

Conversation

data-pup
Copy link
Member

@data-pup data-pup commented Aug 2, 2018

Continuing on work for #88, adding summaries/total row summaries to the 'monos' sub-command.

@data-pup data-pup requested a review from fitzgen August 2, 2018 22:51
Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful as always @data-pup :)

Feel free to merge once nitpicks are addressed!

)?;
let approx_potential_savings_percent =
(f64::from(entry.approx_potential_savings)) / (f64::from(items.size())) * 100.0;
// Give an entry representing a generic function and it various
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: "Give" -> "Given", "and it various" -> "and its various"


let get_size_percent = |x: u32| f64::from(x) / total_size * 100.0;

let mut rows = vec![TableRow {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function could return -> impl Iterator<Item = TableRow> and avoid separate heap allocations for each vec. Not a big deal, though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh neat! So, I think I took care of this, but I'm not completely sure? I'll hold off on merging this until you have a chance to check on the revised version, but I'd like to try and do it the way you mentioned :)

size: *size,
size_percent: f64::from(*size) / total_size * 100.0,
size_percent: get_size_percent(*size),
name: name.to_string(),
}].into_iter()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The vec![..] will still allocate the heap elements, what we want to do is

use std::iter;

iter::once(TableRow {
    ...
}).chain(...)

instead of using vec![] here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omg! Okay that's how to do this! I had been having trouble with plain arrays, I didn't know about iter::once. I'll take care of that today, thanks for the tip!

@data-pup
Copy link
Member Author

data-pup commented Aug 3, 2018

Took care of the vec! issue mentioned above, and squashed all of these commits down in preparation to merge 😄

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thansk @data-pup!

@fitzgen fitzgen merged commit d0da2df into rustwasm:master Aug 3, 2018
@data-pup data-pup deleted the add-monos-summary-pr branch August 20, 2018 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants