[fpc-pascal]Profiling and classes
Preben Mikael Bohn
preben at chin.dk
Sun Mar 30 18:44:08 CEST 2003
Hi all, I am trying to write a basic object-oriented matrix library, but have
run into a problem.
I expected my OO routines to be somewhat slower than my equivalent non-OO
routines, which was also the case (the non-OO routines uses 10 sec for a
500x500 matrix inversion, while the OO routines uses 110 secs (!) for the
same).
To analyse where the problem is I have used the -pg option to make output for
use in the GNU profiler, gprof. In the non-OO program I get the following:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
41.27 4.42 4.42 501 0.01 0.01 _FORWARDSUBS...
30.44 7.68 3.26 501 0.01 0.01 _BACKWARDSUBS..
28.20 10.70 3.02 2 1.51 1.51 _LUDECOMPOSITION$TAR
0.09 10.71 0.01 1 0.01 10.71 program_init
As you can see the cumulative seconds are equal to the time I measured (using
"time" on the command line).
However when I run the OO program I get something like:
Each sample counts as 0.01 seconds.
% cumulative self self total
time seconds seconds calls s/call s/call name
40.63 14.13 14.13 249874780 0.00 0.00 _SIMPLE..
[snip - a lot of lines]
0.00 34.78 0.00 1 0.00 34.75 program_init
Here the cumulative seconds only shows 34.78 seconds, even though the output
from "time" gives 110 seconds...
Can anyone tell me what is going on? I guess it means that it uses a lot of
time (~70%) in some internal FPC routines I have no control over?
Best regards Preben
PS: It should be mentioned that in both cases the computer had nothing else to
do, and that the "time" command estimated the CPU usage to be 99%.
More information about the fpc-pascal
mailing list