[Gambas-user] Performance figures for various ways to do reflective method calls

Benoît Minisini benoit.minisini at gambas-basic.org
Tue Oct 17 20:27:11 CEST 2023


Le 17/10/2023 à 20:22, Benoît Minisini a écrit :
> Le 17/10/2023 à 20:07, Martin Fischer a écrit :
>> Hi Brian,
>>
>> I got the same results using my original tests with "fast" and "fast
>> unsafe".
>> I was quite surprised to see that mostly it's not getting faster with
>> "fast".
>>
>> This raises the question: under which circumstances is "fast" faster?
>> Benoit, can you answer this?
>>
>> Regards,
>> Martin
>>
> 
> Have you read the wiki page about JIT compiler?
> 
> In a few words, a lot of things are optimized, and the others just call 
> the interpreter indirectly. So no gain for string management, and 
> function calls can be slower - it is only optimized when you call a 
> class private function.
> 
> Regards,
> 

Another remark: when you call a method on a object whose type may change 
(i.e. Object, Variant), it's slow, as the class symbol table must be 
browsed. When the object has a defined datatype (inheritance is taken 
into account), then the class symbol table is only browsed once, the 
first time the line of code is executed. This is called "lazy binding". 
The other method calls are then faster, as the class symbol table is not 
browsed anymore. Moreover, if the method signature is "simple", i.e. no 
optional argument, no use of "...", no "ByRef", then the method call is 
faster.

Regards,

-- 
Benoît Minisini.



More information about the User mailing list