IPhone / iPad: Does many NSLog () calls have an impact on application or memory performance?

I would like to know if many NSLog () calls affect application performance or memory. Does anyone know of such a thing?

I want to put an NSLog () call in every function in my application (which is a lot) so that I can see the logs after and trace failures.

Thanks.

+6
source share
3 answers

Yes. Therefore, I define this in my pch file.

#ifdef DEBUG # define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); #else # define DLog(...) #endif // ALog always displays output regardless of the DEBUG setting #define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__); 

Instead of using NSLog, I use DLog and ALog.

(Note or copyright: I got this code long ago from some other SO message that I don't remember. Inserting it again from my snippet library)

+10
source

Another simple solution to undefine NSLog

In the .pch file:

 #ifndef DEBUG #define NSLog(...) /* */ #endif 
+7
source

Yes, it slows down performance, especially if a function should take a very short time, NSLog (which is an I / O process) will cause it to take longer than expected.

+2
source

Source: https://habr.com/ru/post/897567/


All Articles