flamegraph-rs / flamegraph

Easy flamegraphs for Rust projects and everything else, without Perl or pipes <3
Apache License 2.0
4.6k stars 141 forks source link

Cannot run benchmarks for library crate #80

Open m-schubert opened 4 years ago

m-schubert commented 4 years ago

Some strange oddities. I'm currently developing a quick Python module in Rust to do curve simplification, and I'm trying to use flamegraph to help me profile the code.

Running a specific benchmark works fine:

[shoobs@fabiana curved]$ cargo bench --bench rdp
   Compiling curved v0.1.0 (/home/shoobs/Code/curved)
    Finished bench [optimized + debuginfo] target(s) in 3.30s
     Running target/release/deps/rdp-6098376c514929c6

running 1 test
test large_2d ... bench:  75,888,252 ns/iter (+/- 10,891,873)

test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured; 0 filtered out

Trying to run flamegraph for the same benchmark:

[shoobs@fabiana curved]$ cargo flamegraph --bench rdp
   Compiling pyo3 v0.9.0
   Compiling numpy v0.8.0
   Compiling curved v0.1.0 (/home/shoobs/Code/curved)
    Finished release [optimized] target(s) in 9.50s
could not find desired target rdp in the bench targets for this crate

It's also odd that running flamegraph forces a recompile of a few libraries even after running the benchmark immediately before.

nanne007 commented 4 years ago

Same problem here.

arnej commented 3 years ago

I had the same issue and created #102 which fixes this for me.

JAicewizard commented 3 years ago

I was just looking into this and seeing if I could fix it. this does indeed fix it! thanks I hope that gets merged

sloane-shark commented 3 years ago

I'm using flamegraph-rs on nixos and I don't have a great way of overriding to arnej's repo for the time being... would love to see #102 merged so it can find it's way downstream :)

EDIT: just looked at the PR, I think it's possible this is occurring for me with a test rather than a benchmark, but I'm not totally sure.

kdy1 commented 3 years ago

I created a new tool, which fixes this issue and supports arguments on mac properly

See: https://github.com/kdy1/cargo-profile