It’s better to check it out yourself. You are the one who knows your application best and can say what is the most optimal solution in special conditions. This is a simple test script that you can use. It simply saves the current timestamp using the unit / C # method and the registration time required for this operation.
public class TimeTest : MonoBehaviour
{
public bool UseUnityFuntion;
private string msg;
void Update ()
{
var stopwatch = Stopwatch.StartNew();
msg = UseUnityFuntion
? Time.time.ToString()
: DateTime.UtcNow.Millisecond.ToString();
stopwatch.Stop();
UnityEngine.Debug.Log(stopwatch.ElapsedTicks);
}
void OnGUI()
{
if (msg != null) GUILayout.Label(msg);
}
}
As in most cases, this non-unity function seems faster. At least on my computer. I don’t know how the application works, but keep in mind that you may encounter when using the Miliseconds value. There is also one drawback to using Time.time - you can only do this in the main thread. When you have a network application, there is a good chance that you want to save the timestamp in the background thread.