Is there any way for me to tell which part of the code took the most of the time?

Hey there, i am currently using rust to implement some algorithms. However I am not satisfied with the time, which obviously can be optimized.

All i am asking is that, is there any way for me to find out which part of the code took most the time so that i can cut off the time.

Forgive my poor English as i am not a native English speaker

I've personally had a very good experience using flamegraph-rs.

1 Like

I'd like to point out in particular this paragraph "Flamegraphs Are the Beginning, Not the End" which gives more information about how to measure performance of programs beyond flamegraphs.

Definitely. When you've started to identify the hot spots, build a set of micro-benchmarks to make sure things improve where you hope and your optimization efforts are not creating performance regressions elsewhere.

Criterion has worked well for me for micro-benchmarking. Criterion.rs - Criterion.rs Documentation

Make sure you're running cargo run --release as well.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.