Page 1 of 1
Speed on PB is slow ?!
Posted: Tue Aug 12, 2025 4:01 pm
by threedslider
Hi
I make a simple for the loop to 1 000 000 000 and it is quite slow
See it by yourself
Here the code :
Code: Select all
Procedure.i Adder(i.i)
ProcedureReturn i + 1
EndProcedure
i.i = 0
TimeStart = ElapsedMilliseconds()
While i < 1000000000
adder(i)
i = i+1
Wend
Debug Str((ElapsedMilliseconds() - TimeStart)) + " milliseconds"
And time is here :
Re: Speed on PB is slow ?!
Posted: Tue Aug 12, 2025 4:15 pm
by mk-soft
With Debugger
Without Debugger
Not Slow
Code: Select all
Procedure.i Adder(i.i)
ProcedureReturn i + 1
EndProcedure
If OpenConsole()
i.i = 0
PrintN("Start ...")
TimeStart = ElapsedMilliseconds()
While i < 1000000000
adder(i)
i = i+1
Wend
PrintN("Done " +Str((ElapsedMilliseconds() - TimeStart)) + " milliseconds")
Input()
EndIf
Re: Speed on PB is slow ?!
Posted: Tue Aug 12, 2025 5:10 pm
by TI-994A
threedslider wrote: Tue Aug 12, 2025 4:01 pmI make a simple for the loop to 1 000 000 000 and it is quite slow
Such results are highly contingent on the hardware its running on.
Re: Speed on PB is slow ?!
Posted: Tue Aug 12, 2025 5:50 pm
by le_magn
mk-soft wrote: Tue Aug 12, 2025 4:15 pm
With Debugger
Without Debugger
Hi MK-SOFT, I’d like to ask which CPU you have. Without a debugger, I get 1400ms, but with a debugger, it takes twice your time, 85000ms, PB 6.21 32/64
UPDATE: I repeated the test with C Backend and now this is the result:
CPU: AMD Ryzen 9950X3D
Re: Speed on PB is slow ?!
Posted: Tue Aug 12, 2025 5:57 pm
by NicTheQuick
On my machine the code is done in 0 milliseconds. I guess the optimization is working fine.
Without optimization it is 1512 milliseconds.
So don't forget to enable optimizations in the compiler options.
Re: Speed on PB is slow ?!
Posted: Tue Aug 12, 2025 7:21 pm
by threedslider
@mk-soft : Oh ok I see that xD, yes my without debugger is pretty fast
@TI-994A : true
@NicTheQuick : How you did that ??? Say me your tips please !!
Re: Speed on PB is slow ?!
Posted: Tue Aug 12, 2025 7:41 pm
by NicTheQuick
threedslider wrote: Tue Aug 12, 2025 7:21 pm@NicTheQuick : How you did that ??? Say me your tips please !!
You have to enable the compiler optimizations in the compiler options. And of course for that you have to use the C backend and not the ASM backend. The ASM backend has no future anyway in my opinion.
Re: Speed on PB is slow ?!
Posted: Tue Aug 12, 2025 9:15 pm
by AZJIO
Windows 11 x64, PB 6.21 x64, AMD Ryzen 5 8500G OEM
92614 - ASM, with Debugger
1203 - ASM, without Debugger
32547 - C-Backend, with Debugger, without optimization
26440 - C-Backend, with Debugger, with optimization
1591 - C-Backend, without Debugger, without optimization
201 - C-Backend, without Debugger, with optimization
Re: Speed on PB is slow ?!
Posted: Tue Aug 12, 2025 10:26 pm
by Mindphazer
On my Mac M4 :
Debugger on : 21749 ms
Debuger off without optimization : 1578 ms
Debugger off with optimization : 0 ms
On Mac Mx series, only C Backend is available
PB is slow, really ?
Re: Speed on PB is slow ?!
Posted: Tue Aug 12, 2025 10:29 pm
by BarryG
3167 ms on my very old PC. This is running it as a compiled exe, built with the ASM backend with v6.10 of PureBasic.
Re: Speed on PB is slow ?!
Posted: Wed Aug 13, 2025 2:48 am
by idle
NicTheQuick wrote: Tue Aug 12, 2025 5:57 pm
On my machine the code is done in 0 milliseconds. I guess the optimization is working fine.
Without optimization it is 1512 milliseconds.
So don't forget to enable optimizations in the compiler options.
C Optimizer removed the loop.

Re: Speed on PB is slow ?!
Posted: Wed Aug 13, 2025 9:18 am
by threedslider
@idle : Yeah it is possible

Re: Speed on PB is slow ?!
Posted: Wed Aug 13, 2025 9:20 am
by threedslider
Mindphazer wrote: Tue Aug 12, 2025 10:26 pm
PB is slow, really ?
I know now but only debugger is slow a bit ... Yeah otherwise PB is very fast

Re: Speed on PB is slow ?!
Posted: Wed Aug 13, 2025 10:26 am
by NicTheQuick
idle wrote: Wed Aug 13, 2025 2:48 am
NicTheQuick wrote: Tue Aug 12, 2025 5:57 pm
On my machine the code is done in 0 milliseconds. I guess the optimization is working fine.
Without optimization it is 1512 milliseconds.
So don't forget to enable optimizations in the compiler options.
C Optimizer removed the loop.
Exactly

Re: Speed on PB is slow ?!
Posted: Wed Aug 13, 2025 11:30 am
by Lord
Interesting:
If I use For/Next, the execution time ist just 50% with Debugger on.
C-Backend is selected and Optimization is enabled.
31106 ms to 69440 ms
Without Debugger: both 0 ms
Win11 x64, PB6.20 x64, i5-13400F