DateTime.Now is a performance issue at least on Linux
Not a question, rather a statement for anyone out there searching.
Tried on: Ubuntu 20.04, Unity 2019.4 LTS
on a build on Linux (player), an call to System.Now should not be run in FixedUpdate or Update, it causing quite a performance loss.
Someway it's blocking everything and lower the performance VERY much.
I used DateTime.Now.Millisecond to syncronice data from an other process in a few high frequenced routines plus in a few others, like when pressing mouse button to fire a gun.
Regardless of hardware (I9-10700K) with a high end NVIDIA card the graphics stuttered a bit, and It turned out to be that call to System.Now being the cause.
what I did was at certain non critical times, load System.DateTime.Now and compare to Time.realTimeSinceStartup, and create an offset so I can calculate System time from Time.realTimeSinceStartup.
I do check from time to time at non-critical places if anything gone out of sync which happens from time to time.
Performance gain just from this change for me: 600% or more (!!!)
Your answer
Follow this Question
Related Questions
Removing a script if its only use is the Start function 1 Answer
Performance Problem: Unaccounted time between: LateBehaviourUpdate and CanvasRenderer.SyncTransform 2 Answers
Set Anti-Aliasing as PostEffect or inside QualitySettings or both? performance? 0 Answers
How to know what to focus on for performance enhancement? 1 Answer
Game gets slower for certain resolutions in Unity Editor. What could be possible fix? 0 Answers