I have weirdest question I came up with today since I am going to release application soon. My question is, is it necessary to remove all lines from code which are print("")
. Does it somehow affect the app performance or something?

- 4,477
- 3
- 44
- 92
-
1Suggestion for the future : Use breakpoint actions :) – vadian Aug 30 '16 at 19:36
-
There is some performance penalty for not doing so. – picciano Aug 30 '16 at 19:39
3 Answers
Yes you should remove them. While performance impact maybe minimal, it is still there.
As Marco pointed out, the largest issue is that you make all those print
statements public.
If you log debugging information, you should either disable these messages by default or log them at the Debug level. This ensures that your debugging messages don’t clutter up your (and your users’) logs.

- 8,568
- 12
- 50
- 85
-
-
@Rob ah gotcha. Happen to have a handy link describing how they handle `print`?? curious to see – random Aug 30 '16 at 21:34
-
1Not at my fingertips. I remember the distinction being discussed in WWDC 2014, but don't see the reference right now. I believe they tweaked the `print` implementation (it looks like it's now synchronized), but I've never seen a detailed discussion. I suspect your basic counsel that print statements should be removed is valid, but that document you reference is talking about a different technology, AFAIK. – Rob Aug 30 '16 at 21:42
The problem to leave the print is that you allow the user to read your debug data since if the user read the console of his/her device will read your print lines.
If you dump some important data of your app it could be a problem, otherwise if you print just Here
, Inside
and so on it may not be a problem.

- 4,058
- 1
- 29
- 49
You should definitely get rid of all print statements before production. This is an IO operation that definitely causes performance impact, Main thread is going to wait until print (IO operation is not completed ) . You might want to convert some debug level print into logger.
Here is one more thread that talks about it.

- 1
- 1

- 773
- 5
- 12