dtolnay / cargo-llvm-lines

Count lines of LLVM IR per generic function
Apache License 2.0
413 stars 24 forks source link

feat: add --filter to filter functions shown in output #60

Closed poliorcetics closed 2 years ago

poliorcetics commented 2 years ago

I use this tool regularly, thanks for publishing it!

While using it, I often need to use things like cargo llvm-lines | rg my_crate::module:: to filter the output and avoid being drowned by things I'm not (yet) trying to improve.

The default of the previous solution is that it strips the header and will still pipe the entire output to rg when only 10% of it are useful to me.

This adds a dependency on regex, and using the tool itself:

cg r --release -- llvm-lines --filter regex
  Finished release [optimized] target(s) in 0.06s
   Running `/Users/alexis/.local/cache/cargo_target_dir/release/cargo-llvm-lines llvm-lines --filter regex`
 Compiling cargo-llvm-lines v0.4.19 (/Users/alexis/repos/tp/cargo-llvm-lines)
  Finished dev [unoptimized + debuginfo] target(s) in 0.73s
Lines                Copies              Function name
-----                ------              -------------
51076                1225                (TOTAL)
   28 (0.1%,  0.1%)     1 (0.1%,  0.1%)  core::ptr::drop_in_place<regex::exec::Exec>
   11 (0.0%,  0.1%)     1 (0.1%,  0.2%)  core::ptr::drop_in_place<core::option::Option<regex::re_unicode::Regex>>
    6 (0.0%,  0.1%)     1 (0.1%,  0.2%)  core::ptr::drop_in_place<regex::re_unicode::Regex>