Profiling Rust methods

Hello Rustaceans!

I'm currently working on a project where I need to profile each method in my Rust application. My goal is to automate this process as much as possible. Specifically, I'm looking for a way to ensure that every method is automatically profiled, without the need to manually add profiling code to each method.

I've experimented with creating a procedural macro for this purpose, but I'm still facing challenges in making it work seamlessly. Ideally, I would like the profiling to be dynamic, so that if a new method is added to the code, the profiler automatically includes it without requiring additional manual setup.

I'm wondering if anyone here has tackled a similar challenge or might have suggestions on a better approach. Any advice or examples of how to create an automatic profiling setup for all methods in a Rust application would be greatly appreciated.

Additionally, if there are existing crates or tools that simplify this process, I'd be eager to learn about them. My main objective is to minimize manual intervention in the profiling process and ensure comprehensive coverage of all methods, including any new methods added in the future.

Thank you in advance for your help and insights!

I am not sure what you mean exactly by "I need to profile each method in my Rust application". When I think about CPU profiling I think about tools like flamegraph. As far as I am aware, but I might be wrong on this, there is no need to annotate methods.

Perhaps you can add some detail about what you are doing exactly currently and why you are doing it?

sometimes when we used a programming language for the blind based on
angelscript, we had a profile generator that wrote into a file how
much time a method consumed and took into account all the methods in
the script that were written out if I called stop_profile and I would
need to achieve something like that here as well

2024-01-06 18:36 GMT+01:00, Mick van Gelderen via The Rust Programming
Language Forum

I once asked if function instrumentation via hooks would be possible, because this would allow for function call based profiling. This it is available for other languages like C,C++,Fortran,...) for many compilers (gcc,llvm,intel,amd,pgi,...) via the cyg_function hooks, but there seems to be no interest in the rust community so far. Maybe if more people ask for it it might be implemented at some point.

yes it would be good becausae what you told it will be used in new ngt
project for audiogames that is in c++

2024-01-09 11:53 GMT+01:00, SpinTensor via The Rust Programming
Language Forum

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.