PB 6.40 beta 1 - Speed

Everything else that doesn't fall into one of the other PB categories.
threedslider
Enthusiast
Enthusiast
Posts: 616
Joined: Sat Feb 12, 2022 7:15 pm

PB 6.40 beta 1 - Speed

Post 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 !
User_Russian
Addict
Addict
Posts: 1629
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: PB 6.40 beta 1 - Speed

Post 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.
threedslider
Enthusiast
Enthusiast
Posts: 616
Joined: Sat Feb 12, 2022 7:15 pm

Re: PB 6.40 beta 1 - Speed

Post 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:
User avatar
jacdelad
Addict
Addict
Posts: 2110
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: PB 6.40 beta 1 - Speed

Post by jacdelad »

You are doing 200000 type conversions which are not directly related to the string library.
Good morning, that's a nice tnetennba!

PureBasic 6.30/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/2*DX517, 164TB+82TB+28TB+2TB SSD
Raspi 400/500
User_Russian
Addict
Addict
Posts: 1629
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: PB 6.40 beta 1 - Speed

Post 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))
threedslider
Enthusiast
Enthusiast
Posts: 616
Joined: Sat Feb 12, 2022 7:15 pm

Re: PB 6.40 beta 1 - Speed

Post by threedslider »

From my raytracing is a little more speed again :D

PB 6.40 beta 2 : 4209 ms
User avatar
idle
Always Here
Always Here
Posts: 6233
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: PB 6.40 beta 1 - Speed

Post 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) 

threedslider
Enthusiast
Enthusiast
Posts: 616
Joined: Sat Feb 12, 2022 7:15 pm

Re: PB 6.40 beta 1 - Speed

Post 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:
User avatar
idle
Always Here
Always Here
Posts: 6233
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: PB 6.40 beta 1 - Speed

Post 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
Post Reply