Cargo subcommand to profile binaries.
0.1.4 - Detects invocation outside of rust project. Propagates valgrind memory error up to cargo profiler. Moves process exit/print error function to main.rs so we can create unit tests for underlying functions. This is achieved by a try_or_exit
macro in main.rs. Generally better error handling with result/option combinators (e.g. andthen, okor, etc.). Unit tests initialized in each submodule.
0.1.3 - cargo better integrated. No longer have to specify binary if in rust project w/ cargo.toml. better error messages and exits (e.g. upon compilation errors).
NOTE: This subcommand can only be used on Linux machines.
First install valgrind:
$ sudo apt-get install valgrind
Then you can install cargo-profiler
via cargo install
.
Alternatively, you can clone this repo and build the binary from the source.
$ cargo build --release
Now, copy the built binary to the same directory as cargo.
$ sudo cp ./target/release/cargo-profiler $(dirname $(which cargo))/
Cargo profiler currently supports callgrind and cachegrind.
You can call cargo profiler anywhere in a rust project directory with a Cargo.toml
.
$ cargo profiler callgrind
$ cargo profiler cachegrind --release
You can also specify a binary directly:
$ cargo profiler callgrind --bin $PATH_TO_BINARY
You can limit the number of functions you'd like to look at:
``` $ cargo profiler callgrind --bin ./target/debug/rsmat -n 10
Profiling rsmat with callgrind...
Total Instructions...198,466,456
```
With cachegrind, you can also sort the data by a particular metric column:
``` $ cargo profiler cachegrind --bin ./target/debug/rsmat -n 10 --sort dr
Profiling rsmat with cachegrind...
Total Memory Accesses...320,385,356
Total L1 I-Cache Misses...371 (0%) Total LL I-Cache Misses...308 (0%) Total L1 D-Cache Misses...58,549 (0%) Total LL D-Cache Misses...8,451 (0%)
Ir I1mr ILmr Dr D1mr DLmr Dw D1mw DLmw
```