Everything else that doesn't fall into one of the other PB categories.
threedslider
Enthusiast
Posts: 616 Joined: Sat Feb 12, 2022 7:15 pm
Post
by threedslider » Fri Jan 23, 2026 4:46 pm
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 ?
Mine is PB 6.30 : 4969 and PB 6.40 b1 : 4225 ms
Difference : 775 ms
Have a nice day !
User_Russian
Addict
Posts: 1629 Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia
Post
by User_Russian » Fri Jan 23, 2026 5:00 pm
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
Posts: 616 Joined: Sat Feb 12, 2022 7:15 pm
Post
by threedslider » Fri Jan 23, 2026 9:44 pm
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
jacdelad
Addict
Posts: 2110 Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa
Post
by jacdelad » Fri Jan 23, 2026 9:51 pm
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
Posts: 1629 Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia
Post
by User_Russian » Fri Jan 23, 2026 11:51 pm
jacdelad wrote: Fri Jan 23, 2026 9:51 pm not 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
Posts: 616 Joined: Sat Feb 12, 2022 7:15 pm
Post
by threedslider » Wed Jan 28, 2026 6:19 pm
From my raytracing is a little more speed again
PB 6.40 beta 2 : 4209 ms
idle
Always Here
Posts: 6233 Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand
Post
by idle » 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)
threedslider
Enthusiast
Posts: 616 Joined: Sat Feb 12, 2022 7:15 pm
Post
by threedslider » Fri Jan 30, 2026 1:16 pm
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)
Thanks for sharing this code, I didn't know this code but it works to PB 6.21 as well too
idle
Always Here
Posts: 6233 Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand
Post
by idle » Fri Jan 30, 2026 8:52 pm
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