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 hidden or 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 to mgear
Recent posts
- Testing Unity AI Beta
- Ways to Support UnityCoder Development
- Using UI Slider to Create 5-Star Rating Element
- Game Music Library For Unity (editor plugin)
- Fontastic : Easily Test Fonts in Unity Editor!
- GeoTiff Importer & Terrain Generator for Unity
- Create Baked DropShadow for UI images
- .JP2 Ortho Image Converter to PNG/JPG/TIFF
- Convert LAS/LAZ/PLY pointclouds to GLTF (GLB) Point Meshes (standalone converter)
- Detect SRP (URP or HDRP) with Assembly Definition Version Defines
- [LudumDare57] Theme: Depths
- MotionVector Effect: Object “disappears” when paused
Recent Comments
- on [Asset Store] PolygonCollider2D Optimizer
- on Trajectory Test Scene 2.0
- on Vector3 maths for dummies!
- on UnityHub 3.6.0: Remove Version Control & Cloud Dashboard columns
- on Using RenderDoc with Unity (graphics debugger)
- on UI Scroll View automatic Content height
- on [Asset Store] Point Cloud Viewer & Tools
- on [Asset Store] Point Cloud Viewer & Tools
Coin:
CUgDSbRqFcAumDSAcdKDvuXsw26VdkJe8C8WGUQHBAGS
An article by












good one also, switch to single line log messages:
https://twitter.com/FreyaHolmer/status/1039497474384244739