public void Init()
    {
        checkVals  = new int[collectionSize];
        arrayInt   = new int[collectionSize];
        listInt    = new List <int>(collectionSize);
        hashset    = new HashSet <int>();
        dict       = new Dictionary <int, int>(collectionSize);
        linkedList = new LinkedList <int>();
        stack      = new Stack <int>(collectionSize);
        q          = new Queue <int>(collectionSize);
        fastList   = new FastListInt(collectionSize);
        arrayClass = System.Array.CreateInstance(typeof(int), collectionSize);

        for (int i = 0; i < numCheckVals; i++)
        {
            checkVals[i] = UnityEngine.Random.Range(0, collectionSize);
        }
        for (int i = 0; i < collectionSize; i++)
        {
            arrayInt[i] = i;
            listInt.Add(i);
            hashset.Add(i);
            dict[i] = i;
            linkedList.AddLast(i);
            stack.Push(i);
            q.Enqueue(i);
            fastList.Add(i);
            arrayClass.SetValue(i, i);
        }
    }
コード例 #2
0
    public void Init()
    {
        arrayInt   = new int[numItems];
        listInt    = new List <int>(numItems);
        hashset    = new HashSet <int>();
        dict       = new Dictionary <int, int>(numItems);
        linkedList = new LinkedList <int>();
        stack      = new Stack <int>(numItems);
        q          = new Queue <int>(numItems);
        fastList   = new FastListInt(numItems);
        arrayClass = System.Array.CreateInstance(typeof(int), numItems);

        for (int i = 0; i < numItems; i++)
        {
            arrayInt[i] = i;
            listInt.Add(i);
            hashset.Add(i);
            dict[i] = i;
            linkedList.AddLast(i);
            stack.Push(i);
            q.Enqueue(i);
            fastList.Add(i);
            arrayClass.SetValue(i, i);
        }
    }
コード例 #3
0
    public void Test()
    {
        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : [], resize");
        {
            int[] arrayInt = new int[numIterations];
            //System.Array.Resize(ref arrayInt, numIterations);
            for (int i = 0; i < numIterations; i++)
            {
                arrayInt[i] = i;
            }
        }
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : Array Class, resize");
        {
            System.Array arrayClass = System.Array.CreateInstance(typeof(int), numIterations);
            //System.Array.Resize(ref arrayInt, numIterations);
            for (int i = 0; i < numIterations; i++)
            {
                arrayClass.SetValue(i, i);
            }
        }
        UnityEngine.Profiling.Profiler.EndSample();

        // LISTS
        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : List, resize");
        {
            List <int> listInt = new List <int>(numIterations);

            for (int i = 0; i < numIterations; i++)
            {
                listInt.Add(i);
            }
        }
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : List");
        {
            List <int> listInt = new List <int>();

            for (int i = 0; i < numIterations; i++)
            {
                listInt.Add(i);
            }
        }
        UnityEngine.Profiling.Profiler.EndSample();

        // ARRAYLIST
        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : ArrayList, resize");
        {
            ArrayList arrayList = new ArrayList(numIterations);

            for (int i = 0; i < numIterations; i++)
            {
                arrayList.Add(i);
            }
        }
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : ArrayList");
        {
            ArrayList listInt = new ArrayList();

            for (int i = 0; i < numIterations; i++)
            {
                listInt.Add(i);
            }
        }
        UnityEngine.Profiling.Profiler.EndSample();

        // HASHSET
        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : HashSet");
        {
            HashSet <int> hashset = new HashSet <int>();

            for (int i = 0; i < numIterations; i++)
            {
                hashset.Add(i);
            }
        }
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : Dictionary");
        {
            Dictionary <int, int> dict = new Dictionary <int, int>();

            for (int i = 0; i < numIterations; i++)
            {
                dict[i] = i;
            }
        }
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : Dictionary, resize");
        {
            Dictionary <int, int> dict = new Dictionary <int, int>(numIterations);

            for (int i = 0; i < numIterations; i++)
            {
                dict[i] = i;
            }
        }
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : Linked List");
        {
            LinkedList <int> linkedList = new LinkedList <int>();

            for (int i = 0; i < numIterations; i++)
            {
                linkedList.AddLast(i);
            }
        }
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : Stack");
        {
            Stack <int> stack = new Stack <int>();

            for (int i = 0; i < numIterations; i++)
            {
                stack.Push(i);
            }
        }
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : Stack, resize");
        {
            Stack <int> stack = new Stack <int>(numIterations);

            for (int i = 0; i < numIterations; i++)
            {
                stack.Push(i);
            }
        }
        UnityEngine.Profiling.Profiler.EndSample();


        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : Queue");
        {
            Queue <int> q = new Queue <int>();

            for (int i = 0; i < numIterations; i++)
            {
                q.Enqueue(i);
            }
        }
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : Queue, resize");
        {
            Queue <int> q = new Queue <int>(numIterations);

            for (int i = 0; i < numIterations; i++)
            {
                q.Enqueue(i);
            }
        }
        UnityEngine.Profiling.Profiler.EndSample();

        //NEW
        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : FastList, resize");
        FastList <int> abListResized = new FastList <int>(numIterations);

        for (int i = 0; i < numIterations; i++)
        {
            abListResized.Add(i);
        }
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : FastList");
        FastList <int> abList = new FastList <int>();

        for (int i = 0; i < numIterations; i++)
        {
            abList.Add(i);
        }
        UnityEngine.Profiling.Profiler.EndSample();

        // Specialized list
        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : FastListInt, resize");
        FastListInt fastListIntResized = new FastListInt(numIterations);

        for (int i = 0; i < numIterations; i++)
        {
            fastListIntResized.Add(i);
        }
        UnityEngine.Profiling.Profiler.EndSample();

        UnityEngine.Profiling.Profiler.BeginSample("Collection (add, Int32) : FastListInt");
        FastListInt fastList = new FastListInt();

        for (int i = 0; i < numIterations; i++)
        {
            fastList.Add(i);
        }
        UnityEngine.Profiling.Profiler.EndSample();
    }