Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will NSLog slow my app?

I have a lot of NSLog's in my app - some of which often print large amounts of data - ie results of a search. Will this make an appreciable difference in the speed of my app?

I'm not familiar with macros - would someone be able to suggest one that would enable/disable all NSLogs?

like image 276
JoshDG Avatar asked Oct 12 '13 18:10

JoshDG


3 Answers

Yes NSLog could make your app slower because of its synchronism. To toggle all NSLog

#ifdef DEBUG
#define NSLog(...) NSLog(__VA_ARGS__)
#else 
#define NSLog(...)
#endif
like image 175
pNre Avatar answered Oct 07 '22 01:10

pNre


You should use something like DLog from MY CURRENT PREFIX.PCH FILE. It'll disable logging in the Release build. This is a great explanation of why you shouldn't keep NSLog's in the Release build.

like image 25
Arek Holko Avatar answered Oct 07 '22 02:10

Arek Holko


If your app is for production try to minimize them. Keep only the ones useful for errors or possible warnings. If you used them for helping you debug, then I advise you to remove them.

like image 1
ipinak Avatar answered Oct 07 '22 01:10

ipinak