7
2018
Faster Debug.Log
Debug.Log() slows down your editor or even hangs if it happens to run inside some long loop,
but you can make it faster by disabling stacktrace from Debug.Log()! (see image above)
Tested for-loop with 100000 iterations in editor (Unity 2018.1.6f1)
– 25000ms with stacktrace enabled
– 2200ms with stacktrace disabled
code used for measuring:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// measure debug.log with large loop | |
using UnityEngine; | |
public class LogSpamTest : MonoBehaviour | |
{ | |
void Start() | |
{ | |
var stopwatch = new System.Diagnostics.Stopwatch(); | |
stopwatch.Start(); | |
for (int i = 0; i < 100000; i++) | |
{ | |
Debug.Log(i); | |
} | |
stopwatch.Stop(); | |
Debug.Log("Timer: " + stopwatch.ElapsedMilliseconds); | |
stopwatch.Reset(); | |
// with stacktrace = 25000 ms | |
// without stacktrace = 2200 ms | |
} | |
} |
References
– https://docs.unity3d.com/Manual/Console.html
Related Posts
1 Comment + Add Comment
Leave a comment
Recent posts
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
- Custom Unity Hub Project Template Preview Image/Video (using HTML+CSS in package description)
Recent Comments
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- ffmpeg stream raw video into Unity Texture2D on
good one also, switch to single line log messages:
https://twitter.com/FreyaHolmer/status/1039497474384244739