Chris Lee Member Licensed User Jul 29, 2016 #1 Still learning B4a but my app development is progressing well. The log method is very useful but can slow execution. I notice when running in release mode the logs are still output. Will the logs get stripped out when I create an APK or will they stick around slowing things down? Should I be using the conditional compilation feature to strip them out or is this unnecessary?
Still learning B4a but my app development is progressing well. The log method is very useful but can slow execution. I notice when running in release mode the logs are still output. Will the logs get stripped out when I create an APK or will they stick around slowing things down? Should I be using the conditional compilation feature to strip them out or is this unnecessary?
mangojack Expert Licensed User Longtime User Jul 30, 2016 #2 I found nothing and cannot comment on Logs /Performance .. but it was just natural to rem Log lines prior to release. I don't think they are stripped/removed prior to compile. I did find a simple suggestion from @Erel which I never thought to do .... You can use Find & Replace tool to replace: Log( with 'Log( Click to expand... Upvote 0
I found nothing and cannot comment on Logs /Performance .. but it was just natural to rem Log lines prior to release. I don't think they are stripped/removed prior to compile. I did find a simple suggestion from @Erel which I never thought to do .... You can use Find & Replace tool to replace: Log( with 'Log( Click to expand...
JakeBullet70 Well-Known Member Licensed User Longtime User Jul 30, 2016 #3 Or my method of madness... Add this to a module. Code: Public Sub debugLog(s As String) #If Debug Log(s) #End If End Sub Upvote 0
Or my method of madness... Add this to a module. Code: Public Sub debugLog(s As String) #If Debug Log(s) #End If End Sub
LucaMs Expert Licensed User Longtime User Jul 30, 2016 #4 JakeBullet70 said: Or my method of madness... Add this to a module. Code: Public Sub debugLog(s As String) #If Debug Log(s) #End If End Sub Click to expand... My old routine: Code: ' Code module Public LogOn As Boolean = True Public Sub MyLog(Msg As String, UseLogColor As Boolean, Col As Int) If LogOn Then If UseLogColor Then LogColor(Msg, Col) Else Log(Msg) End If End If End Sub "old" also because I don't like that UseLogColor, it would be better to check if Col (which should be named Color) is null. Anyway, the "idea" is the same of yours Upvote 0
JakeBullet70 said: Or my method of madness... Add this to a module. Code: Public Sub debugLog(s As String) #If Debug Log(s) #End If End Sub Click to expand... My old routine: Code: ' Code module Public LogOn As Boolean = True Public Sub MyLog(Msg As String, UseLogColor As Boolean, Col As Int) If LogOn Then If UseLogColor Then LogColor(Msg, Col) Else Log(Msg) End If End If End Sub "old" also because I don't like that UseLogColor, it would be better to check if Col (which should be named Color) is null. Anyway, the "idea" is the same of yours
Erel B4X founder Staff member Licensed User Longtime User Jul 31, 2016 #5 Log will not affect the performance of your program unless you call it from a very tight loop. Upvote 0
Chris Lee Member Licensed User Aug 9, 2016 #6 Erel said: Log will not affect the performance of your program unless you call it from a very tight loop. Click to expand... I do have tight loops, so yes performance is impacted. I don't really need them all the time though only when tracking obscure bugs. The commenting out idea is good. I thought about the separate subs suggested by others, but it still means a call to an empty sub routine. I'm a bit obsessional at times about maximising performance. My main question was if the log statements still reside in the final APK. I don't think that question was definitively answered yet? Upvote 0
Erel said: Log will not affect the performance of your program unless you call it from a very tight loop. Click to expand... I do have tight loops, so yes performance is impacted. I don't really need them all the time though only when tracking obscure bugs. The commenting out idea is good. I thought about the separate subs suggested by others, but it still means a call to an empty sub routine. I'm a bit obsessional at times about maximising performance. My main question was if the log statements still reside in the final APK. I don't think that question was definitively answered yet?
Erel B4X founder Staff member Licensed User Longtime User Aug 10, 2016 #7 Chris Lee said: My main question was if the log statements still reside in the final APK. Click to expand... Yes. Upvote 0
Chris Lee said: My main question was if the log statements still reside in the final APK. Click to expand... Yes.
JakeBullet70 Well-Known Member Licensed User Longtime User Aug 10, 2016 #8 Then do this. The log will be stripped from your release. Code: #If Debug Log(s) #End If Upvote 0
Chris Lee Member Licensed User Aug 11, 2016 #9 JakeBullet70 said: Then do this. The log will be stripped from your release. Code: #If Debug Log(s) #End If Click to expand... Indeed, that seems to be the best solution. Thanks for all the responses though they all helped. Upvote 0
JakeBullet70 said: Then do this. The log will be stripped from your release. Code: #If Debug Log(s) #End If Click to expand... Indeed, that seems to be the best solution. Thanks for all the responses though they all helped.