[fpc-devel] Optimization for TObject.InheritsFrom (and the 'is' operator)

Bram Kuijvenhoven kuifwaremailinglists at xs4all.nl
Mon Jul 23 12:06:29 CEST 2007


Florian Klaempfl wrote:
> Just curious, did anybody have profiling results which indicate that
> as/is are really a bottleneck?

For Lazarus, I found that about 0.5% of the time is spent in TObject.InheritsFrom (I did two runs). About 50% of this comes from calls in TCustomForm.UpdateActions; the rest is mainly scattered. It is comparable with FillChar, CompareMemRange and CompareText.

So what's a bottleneck? I'm happy it doesn't eat say 10%, 20% or even 50% of CPU time, but imho a serious improvement for a function taking 0.5% -- or more -- is worth some attention.

When using '(AClass.vmtPreOrderIndex <= Self) and (Self <= AClass.vmtLastInSubtreeIndex)', those 0.5% will surely go to less than 0.1%. (Especially if it gets inlined :) )

BTW I played around a bit with valgrind/callgrind and KCacheGrind; these are very nice tools for profiling! The call graphs in KCacheGrind are really nice.

Bram



More information about the fpc-devel mailing list