こんにちは、自分はstructリストの実行時間をテストしていますが、なかなかわからないと面白いことを見つけた。
TransformSystemは構造体Vector3を操作するクラスです。メソッドMoveObjectはリストのアイテムを一個ずつ加算します。

mainメソッドには実行時間を検測します。Loop回数は50000から400000までにします。
実行する結果は以下に表示します。
50000回の結果は何も問題ありませんが、100000回以後の実行結果は全部同じになります。

私の質問は:
私のコードは問題ありますか?もし問題なければ、どうしてこんな現象が発生します?

public class TransformSystem
{
    private readonly List<Vector3> vectorArray;

    public TransformSystem(int capacity)
    {
        vectorArray = new List<Vector3>(capacity);
    }

    public void MoveObject(ref float x, ref float y, ref float z)
    {
        for (int i = 0; i < vectorArray.Count; i++)
        {
            var vector3 = vectorArray[i];
            vector3.x += x;
            vector3.y += y;
            vector3.z += z;
            vectorArray[i] = vector3;
        }
    }

    public void MoveObject(ref Vector3 direction)
    {
        for (int i = 0; i < vectorArray.Count; i++)
        {
            var vector = vectorArray[i];

            vector.x += direction.x;
            vector.x += direction.y;
            vector.x += direction.z;
            vectorArray[i] = vector;
        }
    }
}

internal class Program
{
    public static void Main(string[] args)
    {
        int count = 50000;
        while (count < 500000)
        {
            Console.WriteLine($"===========Count:{count}===========");
            Execute(count);
            count *= 2;
        }
    }

    private static void Execute(int count)
    {
        Vector3 direction = new Vector3{x = 1, y = 1, z = 1};

        Stopwatch sw = new Stopwatch();

        sw.Start();
        TransformSystem system = new TransformSystem(count);
        sw.Stop();
        Console.WriteLine("struct initialization finished. Elapsed: " + sw.Elapsed);
        sw.Reset();

        sw.Start();
        system.MoveObject(ref direction);
        sw.Stop();
        Console.WriteLine("ref struct move finished. Elapsed: " + sw.Elapsed);

        sw.Start();
        system.MoveObject(ref direction.x, ref direction.y, ref direction.z);
        sw.Stop();
        Console.WriteLine("ref struct value move finished. Elapsed: " + sw.Elapsed);
    }
}

===========Count:50000===========
struct initialization finished. Elapsed: 00:00:00.0013711
ref struct move finished. Elapsed: 00:00:00.0002028
ref struct value move finished. Elapsed: 00:00:00.0004169
===========Count:100000===========
struct initialization finished. Elapsed: 00:00:00.0000118
ref struct move finished. Elapsed: 00:00:00.0000001
ref struct value move finished. Elapsed: 00:00:00.0000002
===========Count:200000===========
struct initialization finished. Elapsed: 00:00:00.0000061
ref struct move finished. Elapsed: 00:00:00.0000001
ref struct value move finished. Elapsed: 00:00:00.0000002
===========Count:400000===========
struct initialization finished. Elapsed: 00:00:00.0000062
ref struct move finished. Elapsed: 00:00:00.0000001
ref struct value move finished. Elapsed: 00:00:00.0000002