i use NSLog many times,and i know that it has a delay time .
my app has a delay time ,and i wonder if many logs can create that.
for example, if i have this code :
samplerTimer = [NSTimer scheduledTimerWithTimeInterval: 0.001f target: self selector: @selector(CheckData) userInfo: nil repeats: YES];
NSLog(@"%f",tmp);
the timer is calling a function each 1ms,and it works great, but my concern is that the log takes more time so the timer routine kind of change.
i use hardware,so mseconds are important.
i am trying to understand,what exactly happen during nslog? the system is sleeping? other things are done in parallel ?
how much time exactly does it take ?
NSLog()writes to the standard output or error usingprintf. It will also cause a flush, meaning that the program blocks until the output has been sent to the OS. This is slow.Removing the
NSLog()statements will speed things up a lot. The easiest way to turn all logging off, is adding:in your prefix header (the
.pchfile), below the framework includes. Or you could add this line in the files you want to silence. If effectively replaces allNSLog()statements with0, which does nothing.