From Free Pascal wiki
Jump to: navigation, search


LazProfiler is an IDE addon which adds a One-Click-Profiler to Lazarus.




System Requirements / Dependencies

  • FPC trunk (needs generics and additional PascalParser funktionality)
  • Lazarus trunk (revision 56254 and above)


Download from here and install manually.
It depends on LCLExtension, EpikTimer and VirtualTreeView.

Support page,38983.0.html

Using LazProfiler

Start profiling

  • Open your project (if not done already)
  • Choose Profile from Run menu:
  • Use your program
  • Close your program
  • study LazProfiler output:

Show output

  • Choose "Profiler Results" from View menu:

Cleanup profiler

In case the instrumenting of the sources produce not compileable code you can reset the profiler and tidy things up by choosing
"Cleanup Profiler and restore original files" from Run menu:

Influencing profiling

Hints in source code

By default the profiling automatically starts. If you just want to profile some parts of your code you can surround it by two comments:

// start-profiler
// stop-profiler

Disable instrumenting

If you want to exclude procedures/functions/classes/units from beeing instrumented,
just uncheck the checkbox in front of the procedure/function/class/unit name
in the profiler output window.


Note: Units are onyl visible if tree is sorted by unit.
Classes are only visible if tree is sorted by class or unit.

How does it work?

When profiling is started the following steps are done:

  • project is build to test if project is okay
  • all sources in the projects unit and include directories are backuped (except units below fpc and lazarus source directories)
  • procedures and funtions in units are instrumented with special profiling code
  • project is build with instrumented code
  • instumented sources are deleted and backups are restored
  • program is run with no debugger
  • profiling result is shown when program ends

Known issues

  • Profiling does not stop counting at ShowModal, ShowMessage, ...
  • Profiling for packages in subfolders of project does not work (disable such units for the time being)

Version History

    • Initial release
    • leaving sources instrumented if compile after instrumenting fails
    • checking if backup was successfully created before writing instrumented code to original file
    • renamed menu entries
    • include IncludePath. Patch by zamtmn.
    • minor refactoring
    • fixed recognition of declared record in procedure var section
    • fixed memory leaks
    • new Result-TreeView
      - group by Unit
      - group by Object
    • fixed include handling
    • last group and sort column and order is saved to settings file now
    • refactoring