Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Debug.Log cause latency in Unity builds? [closed]

My colleagues say that remaining Debug.Log causes latency. But I think it is useful for enhancing and accelerating our development. Furthermore, I found there is an option that disables Debug.Log on the production environment.

Give me your opinions.

like image 777
Yoosam Kang Avatar asked Mar 16 '17 15:03

Yoosam Kang


Video Answer


1 Answers

When a Debug.Log() is called, it can affect performance because it will do some stack trace parsing and then write some stuff to a file.

It has to dig right down into the stack trace so if you have a lot of Debug.Logs then you might see a performance hit in your build.

You might want to circumvent this by only calling your Debug.Log statements when in Debug Build. From the Unity Docs:

In the Build Settings dialog there is a check box called "Development Build".

So you could do something like this that will only be called if the box is checked:

if (Debug.isDebugBuild) {
     Debug.Log ("If you can see this, you are in Debug Mode");
}

An easier alternative is to go to Player Settings and un-check "Use Player Log": enter image description here

This will stop Log files being written.

like image 90
Ḟḹáḿíṅḡ Ⱬỏḿƀíé Avatar answered Sep 18 '22 23:09

Ḟḹáḿíṅḡ Ⱬỏḿƀíé