Reputation: 6450
I was wondering if writing to the LogCat affects the speed of the device in any noticeable way. For example if I make 100 Log.d() method calls, will this slow down the application? I cannot imagine it does, but I am just making sure.
Upvotes: 2
Views: 830
Reputation: 7672
Remdroid's answer is actually incorrect. Using a heavy amount of logging will affect your app's performance. However, you will probably not be able to notice any real amount of different unless you're writing a whole lot. For example, I occasionally instrument apps to dump call logs every time that they hit a system call, which is pretty often. At this rate, there is a significant amount of stuff going on. Remember, writing to the log is IO, and at some level, it taken and written to a buffer across the app's boundary.
Remember, you have to be doing a whole lot of logging to really hurt yourself. What most developers do, if they are worried about this, is to make an auxiliary class that implements logging. When you want to switch to a production version of the app, and want to get rid of all your debugging logging, you can simply turn the method to dump to a log into a method that simply returns. (Note that even on devices without JIT, these will be safely optimized away and the function won't even be called.)
P.s., remember that any production stable app should turn debugging logging off, as it's unprofessional to leave it in anyway!
Upvotes: 5