When you have a performance problem, profiling an application will help you figure out where the bottleneck is. However, most profiling tool have a tendency to slow down the execution by a significant factor and EiffelStudio is unfortunately no different. Nevertheless, we have added a neat class called
To make sure you are using this class properly you should know the following:
- Profiling should be enabled in the project settings
- First executed instruction should be a call to
- Last executed instruction should be a call to
- When profiling a section of code the calls
start_profilingand stop_profiling, they should appear in the same routine, as otherwise the profiler will be confused
With EiffelStudio 6.0, there is also a very handy feature that comes for free with the new project settings structure with libraries. By default libraries do not inherit the `profiling' setting and are therefore excluded from the profiling (thus speeding up the profiling). It simply means that you won't know how much time is spent in a routine from a library, but the time is still accounted for the callers of that routine. If you want to profile a library, you simply need to mark it so in your project configuration.
I've showed that you can profile a certain portion of code, but you can also disable profiling a certain portion too. We use it when profiling the compiler for not tracking the time spent in the parser. Here is an example:
Ok, it looks a little bit more complicated than what you expected. If you do not care about correctness then you know that you can remove:
- the rescue clause if you do not anticipate exceptions
- the `l_is_profiling' local variable if nothing else is enabling/disabling the profiler
Enjoy Eiffel and profiling!