GpProfiler2017
[Delphi] Source code instrumenting profiler for Delphi XE and higher. Other forks support older versions.
Introduction
GpProfile is a source code instrumenting profiler for Delphi. It allows you to easily find bottlenecks and significantly improves perfomance of your Delphi applications. It is a must-have tool for any Delphi developer.
Features are:
- New shiny UI with high DPI support.
- Applying project defines in the parser to support multi-target code.
- A whole lot of bug fixes
- Using
NameThreadForDebugging()for tracing the thread names in the result files. - The PRF output filename can be now be configured using several placeholders, e.g. the ModuleName or the ProcessName and ID.
- 32 and 64 Bit support.
- Low performance impact on the subject that is instrumented.
The generated instrumentation code works with Delphi 2 to the latest version.
How-To
Instrumentation approach
Easy as 1-2-3:
Start gpprof.exe and open your Delphi project file (.dpr)
Check procedures, for which you want to measure execution time. Click "Instrument" button. Special calls will be added in each chosen procedure.
Copy the content of the include dir into your application sources folder or add the include dir to the search path. Build your application in Delphi, run it, do some tasks and close.
After that return to GpProfile window and enjoy the results! :)
Measure Points
Since version 1.6.0, you can add measure points:
Use CreateMeasurePointScope or the low-level API (ProfilerEnterMP and ProfilerExitMP functions) from GpProf.pas to create a measure point. When the scope is released, the measure point will write out the timings.
uses
GpProf;
...
// Using measure point scope
var mp1 := CreateMeasurePointScope('MP-1');
... // do some work
mp1 := nil;
uses
GpProf;
...
// Using low-level API (zero memory allocation)
ProfilerEnterMP('MP-1');
... // do some work
ProfilerExitMP('MP-1'); // make sure to pass exactly the same name as in ProfilerEnterMP
Credits
Original copyright: Primoz Gabrijelcic (gabr@17slon.com)
Small changes to make it work with Delphi 2009, 2010, XE: Anton Alisov (alan008@bk.ru)
Small changes to make it work with Delphi XE2, XE3: Johan Bontes (johan@digitsolutions.nl)
The original project gpprof2011 can be found here: https://code.google.com/archive/p/gpprofile2011/.
It was released under the GPLv2.
Building the sources
Go here for more details.