[futurebasic] Re: [FB] FBtoC Container function speed in C

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 2008 : Group Archive : Group : All Groups

From: Michele Neri <nerimic@...>
Date: Mon, 7 Apr 2008 15:53:35 +0200
FBtoC is slower but could handle correctly the following code:

dim as container gCont
gCont = ""
gCont += string$( 255, "a") + "test"
print gCont

FB is faster but emits a string length error for that code.

In this particular case, when the left term is a container and the 
first item in the right term is a string:

- FBtoC parses each items in the concatenation and add they to a temp 
container that is copied to the left term.

- FB adds each item in the right term to a temp string and copies 
that in the left term.

FBtoC could add more that 255 characters in that line, FB only 255.

It's possible to speed up FBtoC reintroducing such limitation.

In my opinion it's better to document the slow down, recommending to 
split complex operations when speed is important.

Michele.

>Walter Lenk wrote:
>
>>I have been working on converting one of my utility programs for 
>>FBtoC, and have run into a significant speed issue with the 
>>implementation of containers in C.
>
>
>Well-spotted, thanks Walter. I mades a new bug report.
>
>347	Open	performance issue with container += string + string
>
>Code under test:
>[1] gCont += chr$( 13 ) : gCont += chr$( 13 )
>[2] gCont += chr$( 13 ) + chr$( 13 )
>[3] gCont = gCont + chr$( 13 ) : gCont = gCont + chr$( 13 )
>[4] gCont = gCont + chr$( 13 ) + chr$( 13 )
>
>Times for 10000 repetitions:
>      FBtoC       FB
>[1]  0.0036 s    0.0233 s
>[2]  0.1719 s    0.0081 s  <--- performance bug in FBtoC
>[3]  0.3432 s    0.6025 s
>[4]  0.1721 s    0.4306 s
>
>FBtoC actually beats FB on 3 of the 4 tests, but handles #2 very poorly.
>
>Robert P.