B4J Question Debug mode is much slower than Release mode when using resumable subs

xulihang

Active Member
Licensed User
Longtime User
I found that the debug mode is very slow when testing the project which I have uploaded at this thread:
https://www.b4x.com/android/forum/t...en-many-subs-are-stringed.106328/#post-665791

The result of processing a novel:

Debug Mode

B4X:
Waiting for debugger to connect...
Program started.
A3 Start
start time: 10:12:28
end time: 10:13:11
A3 End


Release Mode

B4X:
A3 Start
start time: 10:35:36
end time: 10:35:42
A3 End
 

xulihang

Active Member
Licensed User
Longtime User
Tested again on B4J 7.32. It is faster than the previous test. As this is debug mode, perhaps this result is reasonable. And it is an indication that my code needs optimization.

B4X:
Waiting for debugger to connect...
Program started.
A3 Start
start time: 12:30:10
end time: 12:30:38
A3 End
 
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
you should not use Dim inside a loop, it would create a new class object that is mostly unnecessary.

simple example:
at i 1,2,3 the output of a is empty
B4X:
Sub Test
   
    Dim i As Int
    For i = 0 To 3
        Dim a As String
        If i=0 Then a= "Hallo"
        Log(i)
        Log(a)
    Next
   
End Sub

about optimization,
count which sub is most used, also check which sub take the most time.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…