Delphi profiling made simple… really simple!

CodeGear, Delphi for Win32, Programming, Uncategorized Add comments

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.

UPDATE:

Actually AsmProfile is an “Instrumenting” profiler. It uses runtime function detouring and assembly to profile any selected function.

If you dont know differences between Instrumenting profiler and Sampling profiler, you can go here or here and read about it.

So, Suppose to have a slow code like this:

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.

UPDATE:

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

5 Responses to “Delphi profiling made simple… really simple!”

  1. Fred Says:

    Hi,

    thanks for the post, I was looking for a not to intrusive profiler, this one seems good ! I’m going to look at it.

  2. Eric Says:

    asmprofiler is actually an instrumenting profiler.

  3. corrado Says:

    @ fred:
    You can find another sampling profiler here:
    http://delphitools.info/samplingprofiler/

    this tool perform sampling profiling without change your code!

    ciao

  4. Roman Says:

    Another very goood Sampling Profiler is the “SamplingProfiler” from Eric Grange.
    http://delphitools.info

    This Profiler requires no Source changes and works with the Debug-Infos (MAP-Files / TD32)

  5. sampling unit Says:

    [...] Gruen, Fred Argy, James Farrell, Don Arthur, Paul Frijters, and cartoonist Colin Wicking. Club …while true do; Blog Archive Delphi profiling made simple …For example, AsmProfile is an Open Source sampling profiler wich is very simple to use. … Another [...]

Leave a Reply

You must be logged in to post a comment.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in