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

Martin Fischer martin.fischer6 at web.de
Tue Oct 17 20:07:26 CEST 2023


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

On 17.10.23 03:02, Brian G wrote:
> I find this interesting, I ran a baseline call set as well results:
>
> Main.Main.15: Start method Local direct as baseline...integer parameter
> Main.Main.20: Done in 652ms
> Main.Main.22: Start method Local direct as baseline... object parameter
> Main.Main.27: Done in 603ms
> Main.Main.29: Start method direct class static call...
> Main.Main.34: Done in 736ms
> Main.Main.36: Start method direct module  method call...module
> Main.Main.41: Done in 736ms
> Main.Main.43: Start method direct call...
> Main.Main.48: Done in 679ms
> Main.Main.50: Start method direct call... object
> Main.Main.55: Done in 1439ms
> Main.Main.57: Start method reflective call...
> Main.Main.62: Done in 5487ms
> Main.Main.69: Start method eval call...
> Main.Main.76: Done in 4246ms
> Main.Main.78: Start blind method variant call...
> Main.Main.85: Done in 1403ms
>
> but with fast unsafe, some types are actually slower......
>
> Main.Main.15: Start method Local direct as baseline...integer parameter
> Main.Main.20: Done in 152ms
> Main.Main.22: Start method Local direct as baseline... object parameter
> Main.Main.27: Done in 163ms
> Main.Main.29: Start method direct class static call...
> Main.Main.34: Done in 964ms
> Main.Main.36: Start method direct module  method call...module
> Main.Main.41: Done in 937ms
> Main.Main.43: Start method direct call...
> Main.Main.48: Done in 945ms
> Main.Main.50: Start method direct call... object
> Main.Main.55: Done in 1203ms
> Main.Main.57: Start method reflective call...
> Main.Main.62: Done in 5413ms
> Main.Main.69: Start method eval call...
> Main.Main.76: Done in 4638ms
> Main.Main.78: Start blind method variant call...
> Main.Main.85: Done in 1412ms
>
>
> "Failure is the key to success;
>   each mistake teaches us something"  .. Morihei Ueshiba
> Brian G
>
> ----- On Oct 17, 2023, at 12:19 AM, Brian G brian at westwoodsvcs.com wrote:
>
>> Hi martin,
>>
>>   There is one more method to use which is defining ckey as an object
>>     Dim key3 As Object = New Ckey
>>     Debug "Start method direct call... object"
>>     startTime = Now()
>>     For i As Long = 1 To iterations
>>         result = key3._equals(key2)
>>     Next
>>     Debug Subst("Done in &1ms", DateDiff(startTime, Now, gb.Millisecond))
>>
>> the timing looks like this
>> Main.Main.15: Start method direct call...
>> Main.Main.20: Done in 765ms
>> Main.Main.22: Start method direct call... object
>> Main.Main.27: Done in 1156ms
>> Main.Main.29: Start method reflective call...
>> Main.Main.34: Done in 5220ms
>> Main.Main.41: Start method eval call...
>> Main.Main.48: Done in 4554ms
>> Main.Main.50: Start blind method variant call...
>> Main.Main.57: Done in 1332ms
>>
>>
>> "Failure is the key to success;
>> each mistake teaches us something"  .. Morihei Ueshiba
>> Brian G
>>
>> ----- On Oct 13, 2023, at 4:47 PM, Martin Fischer martin.fischer6 at web.de wrote:
>>
>>> Hi fellow gambassians,
>>>
>>> I was interested in the performance of reflective method calls in
>>> gambas. I tested:
>>> - direct (early bound) method call
>>> - reflective via Object.Call
>>> - reflective via gb.eval
>>> - reflective via Variant
>>>
>>> Here are the numbers:
>>>
>>> Main.Main.11: Start method direct call...
>>> Main.Main.16: Done in 540ms
>>> Main.Main.18: Start method reflective call...
>>> Main.Main.23: Done in 4135ms
>>> Main.Main.30: Start method eval call...
>>> Main.Main.37: Done in 3469ms
>>> Main.Main.39: Start blind method variant call...
>>> Main.Main.46: Done in 1185ms
>>>
>>> The absolute numbers are not relevant. These figures answer the
>>> question: "how much slower is reflective call compared to direct call".
>>>
>>> Tiny Project is attached, if you want to reproduce.
>>>
>>> Regards
>>> ____________________________________
>>> Martin Fischer
>>>
>>>
>>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----


More information about the User mailing list