Many users asked Embarcadero to include a profiler in the next Delphi for Win32.
Waiting for this, there are some interesting tools for profile a Delphi program.
For example, AsmProfile is an Open Source sampling profiler wich is very simple to use.
Actually AsmProfile is an "Instrumenting" profiler. It uses runtime function detouring and assembly to profile any selected function.
Download AsmProfiler from SVN or project home page (see the end of the article).
Now you can put 2 unit in your uses clause and initialize profiler interface directly in your dpr
So far so good... compile your app with following settings:\ Delphi -> Project Options:
- Linker -> Map file = detailed
- Compiler -> Optimization = off
- Compiler -> Stack frames = on
In this way, the profiler can reach procedures address for profiling phase.\ Run your application and a small form will show up. In this form your must select the profiled methods and then click "Start".
Now stress your application, click "Stop" and then "Show Results".\ In the "results" form will be shown detailed information about program execution.
Every call timing is splitted in "Calls", "Parent Calls" and "Child calls" and some stats has been calculated too.
AsmProfiler It's not complete like AQTime from AutomatedQA, but it's a very usefull tool for every Delphi programmer.
You can find AsmProfiler here but I suggest to download the updated SVN version.
AsmProfile can also profile your code without change source using DllInjection.
When you only have an executable:
- Start your executable
- Start "dllinject.exe" (will show up a console window)
- Get the PID of your executable via Windows Task Manager or Sysinternal Process Exlorer
- Enter this number in the console black
- Start profiling