[fpc-pascal] Basics of profiling

Graeme Geldenhuys graemeg.lists at gmail.com
Mon Sep 6 13:01:38 CEST 2010


On 6 September 2010 10:48, Felipe Monteiro de Carvalho
>
> Does anyone have a link or some info about basic info for doing
> profiling in fpc apps?

You can try Valgrind. I don't know if it is available under Windows.
The other problem is... good luck decyphering the results. Valgrind,
Callgrind, Memgrind, Cachegrind, Coffee grinder [whatever :-)] are
pretty cryptic to me.

The other problem with Valgrind is that it slowed down our
applications so much that it took 5 minutes to get to the main screen.
Totally useless to use, as far as I am concerned.

Recently I took a look at Darius's old project 'fpprofiler. Links
below.  It was over 2 years since anybody worked on it, and riddled
with bugs. I fixed all memory leaks, added some improvements, and used
the new fcl-passrc code included with FPC Trunk (though it only uses
the tokenizer for speed reasons, so FPC 2.4.x should work to - maybe
with minor one line code change).

fpprofiler was quick and easy to use, and it have me results that was
easier to understand. The callgraph is still work in progress, and the
timing results I want to improve too, but that is simply to do with
the report generator code. I recently spoke to Darius, and is is going
to merge my changes (found in GitHub) into the fpcprojects repository,
but he doesn't know when that will be.

We also have some plans for improving parts of fpprofiler, like the
line number issues, and the missing function names under 64-bit system
(bug/missing feature in FPC).

But for quick and easy profiling, I found fpprofiler to suite my needs
just well. Just remember to have your code in some SCM system, because
fpprofiler does modify the code and recompiles it. It had some issue
where it didn't restore your code, but I think I fixed most of those.
Just thought I would mention it - rather be save than sorry, so have a
backup.

Obviously, you can go old-school too, and simply use EpikTimer, to
time certain functions you know to be slow or prone to "hot spots" in
code.


Blog post on using Valgrind:
  http://lazarusroad.blogspot.com/2007/09/using-valgrind-to-profile-fpc.html

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

Git repository with all my recent changes to get fpprofile working
with latest FPC:
  http://github.com/graemeg/fpprofiler



-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/



More information about the fpc-pascal mailing list