Math.Sqrt、Mathf.Sqrtの速度比較をしたので結果を残しておきます。
[ 環境 ]
Unity 2018.4.14.f1
[ 比較結果 ]
Math.Sqrt | 4 ms |
Mathf.Sqrt | 21 ms |
[ スクリプト ]
using System.Collections; using System.Collections.Generic; using UnityEngine; using System; public class PerformanceComparison : MonoBehaviour { void Start() { System.Diagnostics.Stopwatch StopWatch = new System.Diagnostics.Stopwatch(); int Count = 1000000; //Math.Sqrt StopWatch.Restart(); for(float i = 0; i < Count; i++) { float Temporary = (float)Math.Sqrt(i); } Debug.Log(StopWatch.ElapsedMilliseconds); //Mathf.Sqrt StopWatch.Restart(); for(float i = 0; i < Count; i++) { float Temporary = Mathf.Sqrt(i); } Debug.Log(StopWatch.ElapsedMilliseconds); } }