コード例 #1
0
        public void GlobalSetup()
        {
            Random rnd = new Random();


            AICarList = new List <AICar>(nr_of_elements);
            for (int i = 0; i < nr_of_elements; i++)
            {
                AICarList.Add(new AICar {
                    SomePos = rnd.Next()
                });
            }
            //without shuffling it's 2 times faster, but this is probably because of very simple memory allocation going on and small object size, so basically a happy convenience memory wise
            AICarStructList = new List <AICarStruct>(nr_of_elements);
            for (int i = 0; i < nr_of_elements; i++)
            {
                AICarStructList.Add(new AICarStruct {
                    SomePos = rnd.Next()
                });
            }

            //shuffled, shallow copy! refences
            AICarShuffledList = new List <AICar>(AICarList);
            BenchUtility.Shuffle(AICarShuffledList);
            //shuffled, copy from value types
            AICarStructShuffledList = new List <AICarStruct>(AICarStructList);
            BenchUtility.Shuffle(AICarStructShuffledList);

            AICarStructArray = new AICarStruct[nr_of_elements];
            for (int i = 0; i < nr_of_elements; i++)
            {
                AICarStructArray[i].SomePos = rnd.Next();
            }
        }
コード例 #2
0
        public void GlobalSetup()
        {
            position = new Vector3D[nr_of_elements];
            velocity = new Vector3D[nr_of_elements];

            projectileArray = new ProjectileStruct[nr_of_elements];
            //randomize
            Random rnd = new Random();

            for (int i = 0; i < nr_of_elements; i++)
            {
                position[i].X = BenchUtility.NextFloat(rnd);
                position[i].Y = BenchUtility.NextFloat(rnd);
                position[i].Z = BenchUtility.NextFloat(rnd);

                velocity[i].X = BenchUtility.NextFloat(rnd);
                velocity[i].Y = BenchUtility.NextFloat(rnd);
                velocity[i].Z = BenchUtility.NextFloat(rnd);
            }
        }