I was assuming writing debug.log() would have no effect on the performance in the build.
I noticed that my menu runned at about 4 fps in the editor, which turned to 500 fps after removing all the debug.log there. However, it seems that my menu also runs very slowly (presumably also around 4 fps) in the build when I still have these debug.log there.
This leads me to believe that debug.log is still executed (but fails), rather than removed altogether.
Is this the case ? because that would be quite annoying, as I'd have to remove all the debug stuff if I want to make a smooth build.
Apparently this is the case and intentional. Thanks for the answers guys.
I think I'm gonna write a wrapper that's something like:
can't think of debug.log to cause such performance loss other than due to exceptions, but you may want to add a static variable that defines whether you wan't to log or not. this way you don't have to delete every debug.log within the code.
answered Jun 05 '11 at 01:04 PM
I have definitely seen Debug.Log() be a performance problem. Even one can cause a little hiccup on a smallish platform if you have enough going on.
One thing I should mention that took me a little while to realize when I did a similar solution to your DebugLog() function is that often I would end up doing something like:
DebugLog("Here in Func() " + var1 + " / " + var2 + " / " + var3);
The string argument is evaluated whether or not you eventually log them, and they tend to be slow too - especially with concatenation. String.Format() is better, but still, I've come around to commenting these things out when not needed, and using #if UNITY_EDITOR for those I heavily rely on.
answered Jun 19 '12 at 11:22 PM
Removing them all is one option. I would just comment them out, or you can do this like the scripting ref suggests:
answered Jun 05 '11 at 01:12 PM