STARGÅTE wrote:Fast string is implimented es CopyMemoryString()
This function does not allocate memory for the string.
Then it is not much different from PokeS().
In addition, its use does not accelerate the string functions, such as for example FindString(). In which takes a long time to measure the length of the string.
DisableDebugger
Time = ElapsedMilliseconds()
Len = 10
For i=1 To 100000
For y=1 To Len : Next y ; Analog of function Len().
Len + 10
Next i
MessageRequester("", StrF((ElapsedMilliseconds()-Time)/1000, 3))
I think it would be very nice to have fast strings.
Just as User_Russian wrote, add a length descriptor to every string. Makes strings use more memory, but today memory is no issue, speed is more importent in most cases.
the code below yield the following result on my PC (asus laptop with lubuntu):
10 0.000
100 0.000
1000 0.014
10000 1.125
100000 125.365
This means that for strings below 1000 characters the speed of processing sufficient high from my point of view. I think the majority of processed strings are inputs from forms that have less than 1000 characters.
My suggestion:
If we need faster strings a second class of "longstrings" should be defined with the length attached. This should be the real feature request.
But the usual string should be kept. Why?
Because in cases of memory faults, maybe in the string length bytes, the processing will fail and/or we might have a security problem.
OpenConsole()
Str.s
#Text = "1234567890"
mstart =1
y = Int(Pow(10,mstart))
Time = ElapsedMilliseconds()
For i=1 To 100010
Str + #Text
If i = y
PrintN(Str(i)+" "+StrF((ElapsedMilliseconds()-Time)/1000, 3))
mstart = mstart + 1
y = Int(Pow(10,mstart))
Time = ElapsedMilliseconds()
EndIf
Next i
Print( "ende")
Input()
OpenConsole()
Str.s = Space(100010)
mstart =1
y = Int(Pow(10,mstart))
Time = ElapsedMilliseconds()
Pos=0
For i=1 To 100010
s.s=Mid(Str, i, 1)
If i = y
PrintN(Str(i)+" "+StrF((ElapsedMilliseconds()-Time)/1000, 3))
mstart = mstart + 1
y = Int(Pow(10,mstart))
Time = ElapsedMilliseconds()
EndIf
Next i
Print( "ende")
Input()
OpenConsole()
Str.s = Space(100010)
mstart =1
y = Int(Pow(10,mstart))
Time = ElapsedMilliseconds()
Pos=0
For i=1 To 100010
s.s=PeekS(@Str+i, 1)
If i = y
PrintN(Str(i)+" "+StrF((ElapsedMilliseconds()-Time)/1000, 3))
mstart = mstart + 1
y = Int(Pow(10,mstart))
Time = ElapsedMilliseconds()
EndIf
Next i
Print( "ende")
Input()
the comparison yields on my PC (core3 with Ubuntu12.04 -x68) to:
#repeats code above code below
10 0.000 0.000
100 0.000 0.000
1000 0.000 0.000
10000 0.044 0.000
100000 3.431 0.006
Again: for strings of the length of 50KB and below I see no need for change.
For a dedicated long-string, I agree to the new feature.
But: the basic routine should contain a check: if the string-end marking could not be found at the attached byte offset then the string should have a dedicated error marking(e.g. negative string length).
I agree, I am working on a project right now and the slowness of PB's string handling is effecting it's responsiveness. Something that should be improved for the future.
'strings in PB, very slow'
'Just as User_Russian wrote, add a length descriptor to every string'
PB must let .s=.BSTR inside pb internal ,for each string:
.s add size.l:
Structure BSTR
size.l ;"ABC" = 3 (Asc) or 6 (unicode)
s.s ;Never directly WRITE to this; always use bFunctions() to ensure \Size is updated.
EndStructure
then optimize more :
len(string$)=string$\size
...
Keya really have done up an impressive demonstration. Really makes apparent the need for faster string.
I hope User_Russian gets his wish fulfilled.
+1 for me
ʽʽSuccess is almost totally dependent upon drive and persistence. The extra energy required to make another effort or try another approach is the secret of winning.ʾʾ --Dennis Waitley