Page 1 of 1

PB 6.40 beta 1 - Speed

Posted: Fri Jan 23, 2026 4:46 pm
by threedslider
This version PB 6.40 beta 1 is best for speed again !! Really ? Test by yourself with my Raytracing in one week (viewtopic.php?p=623357#p623357) and then compare from PB 6.30 and PB 6.40 b1, what give you the result ? :D

Mine is PB 6.30 : 4969 and PB 6.40 b1 : 4225 ms
Difference : 775 ms

Have a nice day !

Re: PB 6.40 beta 1 - Speed

Posted: Fri Jan 23, 2026 5:00 pm
by User_Russian
The result is the same.
Perhaps you forgot to disable the debugger and select the C backend compiler in PB 6.30.

If you want to compare speed.
PB

Code: Select all

DisableDebugger
t = ElapsedMilliseconds()
s.s
For i=0 To 200000
  s + i
Next
MessageRequester("", Str(ElapsedMilliseconds()-t))
AutoIt

Code: Select all

$t = TimerInit()
$s=""
For $i=0 To 200000
  $s &= $i
Next
MsgBox(0, "", TimerDiff($t))
PB 6.40 - 8300 millisecond.
AutoIt - 60 millisecond.

Re: PB 6.40 beta 1 - Speed

Posted: Fri Jan 23, 2026 9:44 pm
by threedslider
My result is without debugger... :?

Otherwise your comparison to PB and Autoit are impressive, I am sure Fred can improve this speed as well, he has a lot of options :shock:

Re: PB 6.40 beta 1 - Speed

Posted: Fri Jan 23, 2026 9:51 pm
by jacdelad
You are doing 200000 type conversions which are not directly related to the string library.

Re: PB 6.40 beta 1 - Speed

Posted: Fri Jan 23, 2026 11:51 pm
by User_Russian
jacdelad wrote: Fri Jan 23, 2026 9:51 pmnot directly related to the string library.
But the string library converts a number to a string.
OK, this code runs in one second.

Code: Select all

DisableDebugger
t = ElapsedMilliseconds()
s.s
For i=0 To 200000
  s + " "
Next
MessageRequester("", Str(ElapsedMilliseconds()-t))

Re: PB 6.40 beta 1 - Speed

Posted: Wed Jan 28, 2026 6:19 pm
by threedslider
From my raytracing is a little more speed again :D

PB 6.40 beta 2 : 4209 ms

Re: PB 6.40 beta 1 - Speed

Posted: Thu Jan 29, 2026 10:53 pm
by idle
Fred probably hasn't changed the logic for concatenation in a loop yet as it needs a look ahead to determine if that's the desired behaviour or not

this is 6.30 c backend

Code: Select all

Global s1.s  
Global s2.s   
Global l1,l2 
s1 = "hello" 
s2 = "world" 

st = ElapsedMilliseconds() 
For a =0 To 10000 
   s1 + s2 
Next   
et = ElapsedMilliseconds() 
l1 = Len(s1) 

s1 = "hello" 
s2 = "world" 

st1 = ElapsedMilliseconds()
!SYS_PushStringBasePosition();
For a = 0 To 10000 
  !SYS_CopyString(g_s2);
Next 
!SYS_CopyString(g_s2);
!SYS_AllocateString4(&g_s1,SYS_PopStringBasePosition());
et1 = ElapsedMilliseconds() 
l2 = Len(s1) 

out.s = Str(et-st) + " " + Str(et1-st1) + " " + Str(l1) + " " + Str(l2)
MessageRequester("test",out) 


Re: PB 6.40 beta 1 - Speed

Posted: Fri Jan 30, 2026 1:16 pm
by threedslider
idle wrote: Thu Jan 29, 2026 10:53 pm Fred probably hasn't changed the logic for concatenation in a loop yet as it needs a look ahead to determine if that's the desired behaviour or not

this is 6.30 c backend

Code: Select all

Global s1.s  
Global s2.s   
Global l1,l2 
s1 = "hello" 
s2 = "world" 

st = ElapsedMilliseconds() 
For a =0 To 10000 
   s1 + s2 
Next   
et = ElapsedMilliseconds() 
l1 = Len(s1) 

s1 = "hello" 
s2 = "world" 

st1 = ElapsedMilliseconds()
!SYS_PushStringBasePosition();
For a = 0 To 10000 
  !SYS_CopyString(g_s2);
Next 
!SYS_CopyString(g_s2);
!SYS_AllocateString4(&g_s1,SYS_PopStringBasePosition());
et1 = ElapsedMilliseconds() 
l2 = Len(s1) 

out.s = Str(et-st) + " " + Str(et1-st1) + " " + Str(l1) + " " + Str(l2)
MessageRequester("test",out) 

:shock:

Thanks for sharing this code, I didn't know this code but it works to PB 6.21 as well too :shock:

Re: PB 6.40 beta 1 - Speed

Posted: Fri Jan 30, 2026 8:52 pm
by idle
It shows how it should be done by the compiler with < 6.30 When you concat strings like a = b+c+d it grows the temp string and only asigns to "a" once but in a loop you end up with a=a+b, a=a+c, a=a+d ....
So it gets slower as a gets larger since it copies both a + n to temp then assigns it back to a. It's easy to see the problem but not so easy to address without doing a look ahead in the compiler.
The string append is plenty fast otherwise