UnityEngine.Mathf vs Unity.Mathematics.math vs System.Math vs System.MathF

# 0. 言い訳から...
えーと、[Unity Advent Calendar 2023](https://qiita.com/advent-calendar/2023/unity) シリーズ2の9日目です...全然タイムアウトぉお！！

なかなか書くネタが思いつかず、こんなに遅れてしまいましたが、まぁインターネットのどこかには落ちておいてほしい検証記事を今年も投稿しようと思います。

> 余談ですが、「今年も」と言っておりますが、前年も検証記事を書いていました。
今年一年で結構な人に読まれたようで、引用とかもしていただいたみたいです。
ありがとうございますm(__)m

https://qiita.com/Butterfly-Dream/items/4dd770bd2141974dc7c9
# 1. 本題
さて、この記事の本題は、Unityで使用できる算術関連クラスのパフォーマンス比較です。

UnityEngineには標準で `Mathf` クラスが搭載されており、幅広く使用されているかと思いますが、C#のSystem名前空間にも標準で、`Math` クラスが提供されています。

この二つは無関係な代物ではなく、`UnityEngine.Mathf` には単純に `System.Math` のメソッドをラップしているだけのものがあることも知られています。

https://shibuya24.info/entry/unity-csharp-mathf

単なるラップメソッドは当然のことながら、モノホンの `System.Math` には勝てないでしょう。それは自明の理。

しかし、`UnityEngine.Mathf` クラスは、全部が全部 `System.Math` クラスのRapperというわけではありません。

そもそも `UnityEngine.Mathf` クラスにだけあって `System.Math` クラスにないメソッドというものもありますが、共通であるものでもラップ関係にないものもあります。

例えば、`UnityEngine.Mathf.Max()` メソッド。

このメソッドの定義は以下の通りです。

（引数違いで色々と定義があるので、シンプルなfloat型2つの比較のものを掲載します。）

```cs:Mathf.cs
    public static float Max(float a, float b) => (double) a > (double) b ? a : b;
```

わかりやすくていいですね。

まあ、見ての通り、このメソッドに関しては `System.Math` クラスをラップしていません。

ではどちらが速いのか...メモリに優しいのか...それを検証するのが今回の記事になります。
# 2.検証方法
検証方法はありきたりですが、プロファイラーを使った計測になります。

```cs:Bencmark.cs
using System;
using System.Collections;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Profiling;

public sealed class Benchmark : MonoBehaviour
{
    IEnumerator Start()
    {
        // 5秒経過したくらいから計測開始
        yield return new WaitForSeconds(5);

        Profiler.BeginSample(nameof(Mathf.Max));
        for (int i = 0; i < 10000; i++)
        {
            float result = Mathf.Max(10.5f, 11.4f);
        }
        Profiler.EndSample();

        Profiler.BeginSample(nameof(math.max));
        for (int i = 0; i < 10000; i++)
        {
            float result = math.max(10.5f, 11.4f);
        }
        Profiler.EndSample();

        Profiler.BeginSample(nameof(Math.Max));
        for (int i = 0; i < 10000; i++)
        {
            float result = Math.Max(10.5f, 11.4f);
        }
        Profiler.EndSample();

        Profiler.BeginSample(nameof(MathF.Max));
        for (int i = 0; i < 10000; i++)
        {
            float result = MathF.Max(10.5f, 11.4f);
        }
        Profiler.EndSample();
    }
}
```

こんな感じで、10000回実行したときのパフォーマンスを比較していきます。
`Deep Profile` オンでこれを実際に実行すると、以下の結果が得られます。

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/1233990/c6447951-934d-12e2-3b77-1852d2914220.png)

上の例の場合、GCアロケーションは問題なし、速度・負荷ともに `Mathf.Max()` の勝利！でいいと思います。
こんな感じでガリガリ検証していきたいと思います。

:::note info
・Unity 2022.3.12f
・Mono
・.Net Standard2.1
・Mathematics1.2.6
:::
# 3. 検証結果
基本的に、Mathfベースで、他のものでそれに相当するものと比較していきます。

`Unity.Mathematics.math` とかは、`UnityEngine.Mathf` と違う用途で派生しているものなので、単純比較ができるとはそもそも考えていません。

単に、普段使いはどれがいいかな？って検証です。
## 3-1. Static変数
さすがに定数はGCアロケーションもアクセス速度も0ですね。

内部が `public const` なので、差がつくわけもなし...。

`Unity.Mathematic.math.radius()` は厳密にはメソッドなので定数ではないのですが、相当対象として並べておきました。

<table>
  <tbody>
    <tr>
      <td colspan="3">$\small\texttt{UnityEngine.Mathf}$</td>
      <td colspan="3">$\small\texttt{Unity.Mathematics.math}$</td>
      <td colspan="3">$\small\texttt{System.Math}$</td>
      <td colspan="3">$\small\texttt{System.MathF}$</td>
    </tr>
    <tr">
      <td>$\small\texttt{比較対象}$</td>
      <td>$\small\texttt{GC Alloc (B)}$</td>
      <td>$\small\texttt{Time (ms)}$</td>
      <td>$\small\texttt{相当対象}$</td>
      <td>$\small\texttt{GC Alloc}$</td>
      <td>$\small\texttt{Time (ms)}$</td>
      <td>$\small\texttt{相当対象}$</td>
      <td>$\small\texttt{GC Alloc}$</td>
      <td>$\small\texttt{Time (ms)}$</td>
      <td>$\small\texttt{相当対象}$</td>
      <td>$\small\texttt{GC Alloc}$</td>
      <td>$\small\texttt{Time (ms)}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Deg2Rad}$</td>
      <td>0</td>
      <td>0</td>
      <td>$\small\texttt{float radians()}$</td>
      <td>0</td>
      <td>0.48</td>
      <td>$\small\texttt{該当なし}$</td>
      <td></td>
      <td></td>
      <td>$\small\texttt{該当なし}$</td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td>$\small\texttt{float Epsilon}$</td>
      <td>0</td>
      <td>0</td>
      <td>$\small\texttt{float EPSILON}$</td>
      <td>0</td>
      <td>0</td>
      <td>$\small\texttt{該当なし}$</td>
      <td></td>
      <td></td>
      <td>$\small\texttt{該当なし}$</td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td>$\small\texttt{float Infinity}$</td>
      <td>0</td>
      <td>0</td>
      <td>$\small\texttt{float INFINITY}$</td>
      <td>0</td>
      <td>0</td>
      <td>$\small\texttt{該当なし}$</td>
      <td></td>
      <td></td>
      <td>$\small\texttt{該当なし}$</td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td class="s5" dir="ltr">$\small\texttt{float NegativeInfinity}$</td>
      <td>0</td>
      <td>0</td>
      <td>$\small\texttt{該当なし}$</td>
      <td></td>
      <td></td>
      <td>$\small\texttt{該当なし}$</td>
      <td></td>
      <td></td>
      <td>$\small\texttt{該当なし}$</td>
      <td></td>
      <td></td>
    </tr>
    <tr>
      <td>$\small\texttt{float PI}$</td>
      <td>0</td>
      <td>0</td>
      <td>$\small\texttt{float PI}$</td>
      <td>0</td>
      <td>0</td>
      <td>$\small\texttt{該当なし}$</td>
      <td colspan="2">$\small\texttt{(Math.PIはdouble型)}$</td>
      <td>$\small\texttt{float PI}$</td>
      <td>0</td>
      <td>0</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Rad2Deg}$</td>
      <td>0</td>
      <td>0</td>
      <td>$\small\texttt{該当なし}$</td>
      <td></td>
      <td></td>
      <td>$\small\texttt{該当なし}$</td>
      <td></td>
      <td></td>
      <td>$\small\texttt{該当なし}$</td>
      <td></td>
      <td></td>
    </tr>
  </tbody>
</table>

## 3-2. Statuc関数
こちらが本題ですね。
相対対象は自分調べなので、「該当なし」にしているものも、もしかしたらあるかもです。

<table>
  <tbody>
    <tr>
      <td  colspan="3">$\small\texttt{UnityEngine.Mathf}$</td>
      <td  colspan="3">$\small\texttt{Unity.Mathematics.math}$</td>
      <td  colspan="3">$\small\texttt{System.Math}$</td>
      <td  colspan="3">$\small\texttt{System.MathF}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{比較対象}$</td>
      <td>$\small\texttt{GC Alloc (B)}$</td>
      <td>$\small\texttt{Time (ms)}$</td>
      <td>$\small\texttt{相当対象}$</td>
      <td>$\small\texttt{GC Alloc}$</td>
      <td>$\small\texttt{Time ms}$</td>
      <td>$\small\texttt{相当対象}$</td>
      <td>$\small\texttt{GC Alloc}$</td>
      <td>$\small\texttt{Time ms}$</td>
      <td>$\small\texttt{相当対象}$</td>
      <td>$\small\texttt{GC Alloc}$</td>
      <td>$\small\texttt{Time ms}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Abs (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.37}$</td>
      <td>$\small\texttt{float abs}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{4.23}$</td>
      <td>$\small\texttt{float Abs}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.43}$</td>
      <td>$\small\texttt{float Abs}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.47}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{int Abs (int value)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.35}$</td>
      <td>$\small\texttt{int abs}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.38}$</td>
      <td>$\small\texttt{int abs}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.42}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Acos (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.45}$</td>
      <td>$\small\texttt{float acos}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.43}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Acosはdouble型)}$</td>
      <td>$\small\texttt{float Acos}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.52}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{bool Approximately (float a, float b)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{7.86}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Asin (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.57}$</td>
      <td>$\small\texttt{float asin}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.38}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Asinはdouble型)}$</td>
      <td>$\small\texttt{float Asin}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.51}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Atan (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.59}$</td>
      <td>$\small\texttt{float atan}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.50}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Atanはdouble型)}$</td>
      <td>$\small\texttt{float Atan}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.64}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Atan2 (float y, float x)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{3.47}$</td>
      <td>$\small\texttt{float atan2}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.52}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Atan2はdouble型)}$</td>
      <td>$\small\texttt{float Atan2}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.61}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Ceil (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.50}$</td>
      <td>$\small\texttt{float ceil}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.49}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Ceilingはdouble型)}$</td>
      <td>$\small\texttt{float Ceiling}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.50}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{int CeilToInt (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.51}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Clamp (float value, float min, float max)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.46}$</td>
      <td>$\small\texttt{float clamp}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{6.10}$</td>
      <td>$\small\texttt{float Clamp}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.44}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{int Clamp (int value, int min, int max)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.50}$</td>
      <td>$\small\texttt{int clamp}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{2.58}$</td>
      <td>$\small\texttt{int Clamp}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.43}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Clamp01 (float value)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.43}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{int ClosestPowerOfTwo (int value)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.51}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{Color CorrelatedColorTemperatureToRGB (float kelvin)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.65}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Cos (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.47}$</td>
      <td>$\small\texttt{float cos}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.47}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Cosはdouble型)}$</td>
      <td>$\small\texttt{float Cos}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.59}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float DeltaAngle (float current, float target)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{3.54}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Exp (float power)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.80}$</td>
      <td>$\small\texttt{float exp}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.52}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Expはdouble型)}$</td>
      <td>$\small\texttt{float Exp}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.54}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{ushort FloatToHalf (float val)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.52}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Floor (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.46}$</td>
      <td>$\small\texttt{float floor}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.46}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Floorはdouble型)}$</td>
      <td>$\small\texttt{float Floor}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.58}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{int FloorToInt (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.46}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float GammaToLinearSpace (float value)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.68}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float HalfToFloat (ushort val)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.58}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float InverseLerp (float a, float b, float value)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.46}$</td>
      <td>$\small\texttt{float unlerp}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.45}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{bool IsPowerOfTwo (int value)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.48}$</td>
      <td>$\small\texttt{bool ispow2}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.45}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Lerp (float a, float b, float t)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.36}$</td>
      <td>$\small\texttt{float lerp}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.43}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float LerpAngle (float a, float b, float t)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{4.49}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float LerpUnclamped (float a, float b, float t)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.50}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float LinearToGammaSpace (float value)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.65}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Log (float f, float p)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{7.96}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Logはdouble型)}$</td>
      <td>$\small\texttt{float Log}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{7.26}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Log (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.56}$</td>
      <td>$\small\texttt{float log}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.45}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Logはdouble型)}$</td>
      <td>$\small\texttt{float Log}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.58}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Log10 (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.64}$</td>
      <td>$\small\texttt{float log}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.44}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Log10はdouble型)}$</td>
      <td>$\small\texttt{float Log}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.54}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Max (float a, float b)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.44}$</td>
      <td>$\small\texttt{float max}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{2.26}$</td>
      <td>$\small\texttt{float Max}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{2.49}$</td>
      <td>$\small\texttt{float Max}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{3.34}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Max (params float[] values)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.55}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{int Max (int a, int b)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.47}$</td>
      <td>$\small\texttt{int max}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.43}$</td>
      <td>$\small\texttt{int Max}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{int Max (params int[] values)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.47}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Min (float a, float b)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.44}$</td>
      <td>$\small\texttt{float min}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{2.34}$</td>
      <td>$\small\texttt{float Min}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.43}$</td>
      <td>$\small\texttt{float Min}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.37}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Min (params float[] values)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.49}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{int Min (int a, int b)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.43}$</td>
      <td>$\small\texttt{int min}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.43}$</td>
      <td>$\small\texttt{int Min}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{int Min (params int[] values)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.49}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float MoveTowards (float current, float target, float maxDelta)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{3.46}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float MoveTowardsAngle (float current, float target, float maxDelta)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{8.45}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{int NextPowerOfTwo (int value)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.55}$</td>
      <td>$\small\texttt{float ceilpow2}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.45}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float PerlinNoise (float x, float y)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.67}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float PerlinNoise1D (float x)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.65}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float PingPong (float t, float length)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{5.54}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Pow (float f, float p)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.71}$</td>
      <td>$\small\texttt{float pow}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.64}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Powはdouble型)}$</td>
      <td>$\small\texttt{float Pow}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.57}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Repeat (float t, float length)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{2.39}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Round (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.46}$</td>
      <td>$\small\texttt{float round}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.45}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Roundはdouble型)}$</td>
      <td>$\small\texttt{float Round}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{8.81}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{int RoundToInt (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.44}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Sign (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.50}$</td>
      <td>$\small\texttt{float sign}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.48}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Signはint型；0.46ms)}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Signはint型)}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Sin (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.58}$</td>
      <td>$\small\texttt{float sin}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.87}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Sinはdouble型)}$</td>
      <td>$\small\texttt{float Sin}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.58}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float SmoothDamp (float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed, float deltaTime)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{4.93}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float SmoothDampAngle (float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed, float deltaTime)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{9.96}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float SmoothStep (float from, float to, float t)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.61}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td>$\small\texttt{}$</td>
      <td>$\small\texttt{}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Sqrt (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.53}$</td>
      <td>$\small\texttt{float sqrt}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.50}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Sqrtはdouble型)}$</td>
      <td>$\small\texttt{float Aqrt}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.53}$</td>
    </tr>
    <tr>
      <td>$\small\texttt{float Tan (float f)}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.66}$</td>
      <td>$\small\texttt{float tan}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{1.65}$</td>
      <td>$\small\texttt{該当なし}$</td>
      <td  colspan="2">$\small\texttt{(Math.Tanはdouble型)}$</td>
      <td>$\small\texttt{float Tan}$</td>
      <td>$\small\texttt{0}$</td>
      <td>$\small\texttt{0.65}$</td>
    </tr>
  </tbody>
</table>

個人的に驚きだったのは、int型の `System.Math.Max` と `System.Math.Min` ですね。
これは `Profiler` でも、`System.Diagnostics.Stopwatch` でも速度0みたいです。
思わず目を疑ってしまいましたが...。

# 4. おわりに
今回の検証で、各算術関数の内部実装が気になってきたので、また時間があるときにみてみたいと思います。
では、この記事はこの辺で...。
本年もよろしくお願いいたします。

（たぶん、テーブル頑張って設置したせいで、このページ重くなってそう...）