1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
private void Test() { int times = 100000; Profiler.BeginSample("TestNativeArray"); NativeArray<Vector3> v1 = new NativeArray<Vector3>(times, Allocator.Persistent); for (int i = 0; i < v1.Length; i++) { v1[i] = Vector3.zero; } v1.Dispose(); Profiler.EndSample(); Profiler.BeginSample("TestArray"); Vector3[] v2 = new Vector3[times]; for (int i = 0; i < v2.Length; i++) { v2[i] = Vector3.zero; } Profiler.EndSample(); Profiler.BeginSample("TestList"); List<Vector3> v3 = new List<Vector3>(); for (int i = 0; i < times; i++) { v3.Add(Vector3.zero); } Profiler.EndSample(); Profiler.BeginSample("TestArrayList"); ArrayList v4 = new ArrayList(); for (int i = 0; i < times; i++) { v4.Add(Vector3.zero); } Profiler.EndSample(); Profiler.BeginSample("TestQueue"); Queue<Vector3> v5 = new Queue<Vector3>(); for (int i = 0; i < times; i++) { v5.Enqueue(Vector3.zero); } Profiler.EndSample(); Profiler.BeginSample("TestStack"); Stack<Vector3> v6 = new Stack<Vector3>(); for (int i = 0; i < times; i++) { v6.Push(Vector3.zero); } Profiler.EndSample(); } |
- 本文固定链接: http://www.u3d8.com/?p=2048
- 转载请注明: 网虫虫 在 u3d8.com 发表过