[fpc-devel] Optimization for TObject.InheritsFrom (and the 'is' operator)
kuifwaremailinglists at xs4all.nl
Sun Jul 22 23:47:06 CEST 2007
Florian Klaempfl wrote:
> Just curious, did anybody have profiling results which indicate that
> as/is are really a bottleneck?
Though it can heavily depend on the particular application, the results for a large project I'm working on is as follows:
(Used tool: valgrind-callgrind, FPC 2.1.4, i386, Debian Sarge)
105,233,754 PROGRAM TOTALS
6,417,954 ???:0x00071C80 [/lib/libc-2.3.2.so]
5,350,079 ???:malloc [/lib/libc-2.3.2.so]
4,687,338 ???:0x00072260 [/lib/libc-2.3.2.so]
4,458,735 ???:free [/lib/libc-2.3.2.so]
1,847,952 ???:0x000725B0 [/lib/libc-2.3.2.so]
1,189,035 ???:SYSTEM_TOBJECT_$__INHERITSFROM$TCLASS$$BOOLEAN !!! Here it is !!!
1,023,076 ???:0x00015C8D [/lib/libc-2.3.2.so]
(<snip> means its a routine from my app.)
The application does not have a very deep inheritance tree (when compared with e.g. the LCL). It uses 'is'/'as' at some places where polymorphism cannot be used. (Comparable with situations like TPersistent.Assign)
The above shows that it takes a reasonable amount of time (about 1.1%), comparable with some of the other 'time-eaters'. I also profiled with other input files, and the results varied, depending on which part of the program was getting focus (e.g. parsing input files (1.6%), or processing image files (0.4%)).
More profiling could be done to get a more objective point of view, so everyone is invited to provide his or her results :)
Still, I think the above already shows that InheritsFrom is worth /some/ attention.
More information about the fpc-devel