[Gambas-user] updated benchmark

Jussi Lahtinen jussi.lahtinen at gmail.com
Thu Sep 29 01:30:39 CEST 2022


Just for fun I made a crude c version of the same benchmark. It's not
implementing anything like the Integer[] object, but otherwise it is doing
naively the same thing as Gambas. So, *no* c specific tricks used to gain
speed. And for laziness it does not check the allocations or do them in a
sensible way (instead realloc one by one, which is very slow). See
attachment for the code.

5.29s without Fast Unsafe keyword
1.33s (+ 0.22s for JIT, total 1.53s) with Fast Unsafe
0.94s in C (~39% less from the time above)

Really impressive for Gambas. Of course, you wouldn't normally write the
task like that in c, but these comparisons are quite meaningless anyway.


Jussi



On Wed, Sep 28, 2022 at 4:14 PM Jussi Lahtinen <jussi.lahtinen at gmail.com>
wrote:

> Of course, and similarly well written code in C is safe. I only commented
> on usage of the "unsafe" keyword.
>
>
> Jussi
>
> On Wed, Sep 28, 2022 at 8:54 AM Brian G <brian at westwoodsvcs.com> wrote:
>
>> Why use C when gambas will do just fine.
>> Unsafe is only a concept, well written code is safe.
>>
>> --
>> Thanks
>> Brian G
>> Tuesday, 27 September 2022, 03:51PM -07:00 from Jussi Lahtinen
>> jussi.lahtinen at gmail.com:
>>
>> Probably no particular reason, other than it is generally wise to avoid
>> "unsafe".
>> In my opinion, if you want to get closer to the "C territory" because of
>> speed, then you could as well use C.
>>
>> Jussi
>>
>> On Wed, Sep 28, 2022 at 1:12 AM Brian G <brian at westwoodsvcs.com> wrote:
>>
>> By adding fast unsafe to the start of primes.gbs the speed is orders of
>> magnitude faster.
>>
>>
>> Is there a reason not to do this for the benchmarks?
>>
>> 1.5 seconds gbs
>> 5.7 seconds without fast unsafe gbs
>> 16.217seconds for py
>>
>>
>>
>> "Failure is the key to success;
>>  each mistake teaches us something"  .. Morihei Ueshiba
>> Brian G
>>
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>
>>
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>
>>
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220929/f436efad/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: primes.c
Type: text/x-csrc
Size: 1273 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220929/f436efad/attachment.c>


More information about the User mailing list