コード例 #1
0
        public void ComparePoolsPerformance()
        {
            int capacity  = Environment.ProcessorCount * 2;
            var arrayPool = new ObjectPoolArray <DummyPoolable>(capacity);
            var bagPool   = new ObjectPoolBag <DummyPoolable>(capacity);
            var queuePool = new ObjectPoolQueue <DummyPoolable>(capacity);

            //var mpmcQueuePool = new ObjectPoolMPMCQueue<DummyPoolable>(capacity);
            for (int round = 0; round < 10; round++)
            {
                TestPool(arrayPool);
                TestPool(bagPool);
                TestPool(queuePool);
                //TestPool(mpmcQueuePool);
                Console.WriteLine("----------");
            }
        }
コード例 #2
0
 // Use this for initialization
 void Start()
 {
     objectPool = GetComponent <ObjectPoolQueue>();
     objectPool.Init(prefab, initialAmount);
 }