[Gambas-user] '&=' operator optimization
Jussi Lahtinen
jussi.lahtinen at gmail.com
Sat Apr 4 19:14:36 CEST 2020
Sorry, I didn't notice you had fix it already. However there is still
another bug, that can be seen only when JIT is disabled.
Jussi
On Sat, Apr 4, 2020 at 7:58 PM Jussi Lahtinen <jussi.lahtinen at gmail.com>
wrote:
> Current code fails in GambasTester. Could be due earlier bug.
> I highly recommend to automatically run it after compilation. I know it's
> ugly as hell, but it does its job a lot better than nothing.
>
> Jussi
>
> On Sat, Apr 4, 2020 at 5:32 PM Benoît Minisini <g4mba5 at gmail.com> wrote:
>
>> Hi,
>>
>> In the last commit, I implemented an optimization of a common usage
>> pattern of the '&=' operator, where a string is actually used as an
>> accumulation buffer.
>>
>> Look at the following code, where a global string is filled with
>> arbitrary strings:
>>
>> Private $sBuffer As String
>>
>> Public Sub Main()
>>
>> Dim I As Integer
>> Dim C As String
>> Dim J As Integer
>> Dim T As Float
>>
>> T = Timer
>> For I = 1 To 10000
>> For J = 65 To 90
>> C = Chr$(J)
>> $sBuffer &= ".(" & C & ")"
>> Next
>> Next
>>
>> Print Len($sBuffer);; Timer - T
>>
>> End
>>
>> Before the optimization, that code runs in about 6.64 seconds.
>>
>> After the optimization, it runs in 0.026 seconds. More than 250 times
>> faster!
>>
>> Note that the optimization works only if the string buffer is a local or
>> global variable.
>>
>> If you detect any problem or any crash with that optimization, tell me.
>>
>> Regards,
>>
>> --
>> Benoît Minisini
>>
>> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200404/2c25c22e/attachment.html>
More information about the User
mailing list