Difference between revisions of "FPProfiler"

From Free Pascal wiki
Jump to navigationJump to search
m (→‎FPP: typo)
(Added Category:Profiling)
(5 intermediate revisions by 5 users not shown)
Line 32: Line 32:
  
 
[[Image:Fpprofiler_flatreport.png]] [[Image:Fpprofiler_callgraph.png]] [[Image:Fpprofiler_memorychart.png]]
 
[[Image:Fpprofiler_flatreport.png]] [[Image:Fpprofiler_callgraph.png]] [[Image:Fpprofiler_memorychart.png]]
 +
 +
=== Add or Remove fpprof calls to functions via codetools ===
 +
 +
There is a small command line utility that adds or removes fpprof calls to start and end of functions.
 +
See Lazarus soures
 +
components/codetools/examples/addfpprofcalls.lpr
  
 
== Getting the sources ==
 
== Getting the sources ==
 
You can get the latest sources from SVN here:
 
You can get the latest sources from SVN here:
   http://svn.freepascal.org/svn/fpcprojects/fpprofiler
+
   svn checkout http://svn.freepascal.org/svn/fpcprojects/fpprofiler
  
 
Alternatively Graeme Geldenhuys has created a git repository:
 
Alternatively Graeme Geldenhuys has created a git repository:
Line 42: Line 48:
 
This repository is an unofficial one. The SVN repository is therefore advised.
 
This repository is an unofficial one. The SVN repository is therefore advised.
  
You can view the SVN repository online trough this URL:
+
You can view the SVN repository online through this URL:
 
   http://svn.freepascal.org/cgi-bin/viewvc.cgi/fpprofiler/?root=fpcprojects
 
   http://svn.freepascal.org/cgi-bin/viewvc.cgi/fpprofiler/?root=fpcprojects
  
Line 75: Line 81:
  
  
{| BORDER="1" CELLSPACING="0"
+
{| class="wikitable"
!STYLE="background:#ffdead;"|'''Platform'''
+
! Platform !! Architecture
!STYLE="background:#ffdead;"|'''Architecture'''
 
 
|-
 
|-
 
| Linux
 
| Linux
Line 83: Line 88:
 
|-
 
|-
 
| Windows
 
| Windows
 +
| i386
 +
|-
 +
| Mac OS X
 
| i386
 
| i386
 
|}
 
|}
Line 100: Line 108:
  
 
[[Category:Debugging]]
 
[[Category:Debugging]]
 +
[[Category:Profiling]]

Revision as of 17:36, 19 November 2017

Introduction

The Free Pascal Profiler is an effort to create an FPC native profiler, deployable on all platforms and architectures the Free Pascal compiler itself supports. It was initially developed by Darius Blaszyk.

Free Pascal Profiler consists of two tools (fpp and fppview) and some units containing the profiling code that needs to be linked in.

FPP

To compile your project, you pass the same parameters to FPP as you would to FPC. FPP then scans your source code and inserts profiling code in each begin..end block. It also amends the uses clause to link in the fpprof unit. Once done, it compiles your project, which now includes the profiling code. After that, it restores your units to their original state.

FPPInsert

This tool will only insert profiling code, nothing else. It can also do this recursively on one or more folders at a time.

FPPRemove

This tool will only remove profiling code, nothing else. It can also do this recursively on one or more folders at a time.

FPPView

When you run your program that contains the profiling code, it generates an xml file containing all the profiling information. FPPView reads this xml file and generates reports from it. Call counts, timing and call graphs are supported at the moment.

LazProf

A graphical frontend for Lazarus exists. For now it only is able to analyse the log files, but future versions will also enable to compile the application directly with fpp and analyse the results.

Sample screenshots:

Fpprofiler flatreport.png Fpprofiler callgraph.png Fpprofiler memorychart.png

Add or Remove fpprof calls to functions via codetools

There is a small command line utility that adds or removes fpprof calls to start and end of functions. See Lazarus soures

components/codetools/examples/addfpprofcalls.lpr

Getting the sources

You can get the latest sources from SVN here:

 svn checkout http://svn.freepascal.org/svn/fpcprojects/fpprofiler

Alternatively Graeme Geldenhuys has created a git repository:

 http://github.com/graemeg/fpprofiler

This repository is an unofficial one. The SVN repository is therefore advised.

You can view the SVN repository online through this URL:

 http://svn.freepascal.org/cgi-bin/viewvc.cgi/fpprofiler/?root=fpcprojects

Installing

Currently building the tools from commandline is broken. To build them you should use Lazarus. Start by opening the lazarus project files:

 .\fpp\fpp.lpi
 .\fpp\fppinsert.lpi
 .\fpp\fppremove.lpi
 .\fppview\fppview.lpi

and simply build the tools from the IDE. The executables will be placed in the directory:

 .\bin\$(TargetCPU)-$(TargetOS)\

To install the lazarus package, open the package file in Lazarus called:

 .\lazprof\lazprof.lpk

Click on compile and then install. Lazarus will be rebuilt and additionally the package will register two menu items under:

 View > Profile viewer
 Run > Run with profiling enabled

The latter command is still under development, so don't use it.

Platforms / architectures

Because it is completely FPC native, it should work on all platforms and architectures that FPC supports.

Tested platforms/architectures:


Platform Architecture
Linux i386
Windows i386
Mac OS X i386


People are encouraged to add their platform/architecture here if not listed.

Reporting bugs / feature requests

If you find a bug and would like to report it, or you have an idea to expand fpprofiler, please report the issue in mantis and drop a note on the FPC-devel mailinglist. This ensures the issue does not get forgotten. Of course, when a patch is provided, the issue is likely to be resolved much quicker. It's also highly recommended to provide a test program with the reported issue. This program will be added to the test suite to ensure no regressions will go unnoticed.

See also