Hi all,
I was wondering what are my options for checking how well my programs are optimized. Ideally, I'd like to see a Cargo parameter for dumping some internal representation of programs that somehow shows how well my programs are optimized. One example case that I'm interested in is optimization of iter, filter, map, reduce etc. calls. For example, if I have:
blah.into_iter().map(|c| ...).filter(|c| ...).reduce(|c| ...);
(or collect()
instead of reduce()
)
I'd like to see if this is optimized to a single-pass loop that doesn't do intermediate allocations (given the closures don't allocate) and doesn't allocate closures or actually call any closures.
Some of the other cases that I'm interested in are some unwrap() calls that are statically guaranteed to not fail. One example is if I call a function like this:
fn blah(i : u32) -> Option<...> {
if i == 0 {
None
} else {
Some(...)
}
}
... blah(10).unwrap() ...
So I have lots of cases like these that I'd like to investigate a little bit. I can read the assembly but it's a bit too big and complicated for these purposes. It's hard to understand what's really going on at assembly level.
Thanks.