コード例 #1
0
        public void Benchmark_RandomCards()
        {
            int handCount = 1000000;

#if DEBUG
            int repCount = 1;
#else
            int repCount = 40;
#endif
            Console.WriteLine("Random hands: {0}, repetitions: {1}, total: {2}", handCount, repCount, handCount * repCount);

            RandomHandGenerator randomHands = new RandomHandGenerator();
            randomHands.Generate(handCount);
            randomHands.SetMask(5);
            Console.WriteLine("{0} random 5-hands generated", handCount);

            DateTime startTime;
            double   runTime;
            UInt32   checksum = 0;
            startTime = DateTime.Now;
            for (int r = 0; r < repCount; ++r)
            {
                for (int i = 0; i < handCount; ++i)
                {
                    UInt32 value = CardSetEvaluator.Evaluate(ref randomHands.hands[i].CardSet);
                    checksum += value;
#if DEBUG
                    VerifyHandValue(RefEvaluator.Evaluate(randomHands.hands[i].CardSet.bits,
                                                          randomHands.hands[i].CardSet.CountCards()), value);
#endif
                }
            }
            runTime = (DateTime.Now - startTime).TotalSeconds;
            PrintResult(handCount * repCount, runTime, checksum);

            randomHands.SetMask(7);

            Console.WriteLine("\n{0} random 7-hands generated", handCount);

            startTime = DateTime.Now;
            for (int r = 0; r < repCount; ++r)
            {
                for (int i = 0; i < handCount; ++i)
                {
                    UInt32 value = CardSetEvaluator.Evaluate(ref randomHands.hands[i].CardSet);
                    checksum += value;
#if DEBUG
                    VerifyHandValue(RefEvaluator.Evaluate(randomHands.hands[i].CardSet.bits, 7), value);
#endif
                }
            }
            runTime = (DateTime.Now - startTime).TotalSeconds;
            PrintResult(handCount * repCount, runTime, checksum);
        }
コード例 #2
0
        public void Test_RandomCards_Array()
        {
            int handCount = 1000000;
            int rngSeed   = (int)DateTime.Now.Ticks;

            Console.WriteLine("Seed: {0}", rngSeed);
            RandomHandGenerator randomHands = new RandomHandGenerator(rngSeed);

            randomHands.Generate(handCount);
            randomHands.SetMask(7);
            for (int i = 0; i < handCount; ++i)
            {
                UInt32 value = LutEvaluator7.Evaluate(randomHands.hands[i].Cards);
                VerifyHandValue(RefEvaluator.Evaluate(randomHands.hands[i].CardSet.bits, 7), value);
            }
        }
コード例 #3
0
        public void Benchmark_RandomCards_Indexes()
        {
            int handCount = 1000000;

#if DEBUG
            int repCount = 1;
#else
            int repCount = 20;
#endif
            Console.WriteLine("Random hands: {0}, repetitions: {1}, total: {2}", handCount, repCount, handCount * repCount);

            RandomHandGenerator randomHands = new RandomHandGenerator();
            randomHands.Generate(handCount);


            // Force loading and JIT.
            UInt32 checksum = LutEvaluator7.Evaluate(0, 1, 2, 3, 4, 5, 6);
            randomHands.SetMask(7);

            Console.WriteLine("\n{0} random 7-hands generated", handCount);

            DateTime startTime = DateTime.Now;
            for (int r = 0; r < repCount; ++r)
            {
                for (int i = 0; i < handCount; ++i)
                {
                    RandomHandGenerator.Hand h = randomHands.hands[i];
                    UInt32 value = LutEvaluator7.Evaluate(h.c1, h.c2, h.c3, h.c4, h.c5, h.c6, h.c7);
                    checksum += value;
#if DEBUG
                    VerifyHandValue(RefEvaluator.Evaluate(randomHands.hands[i].CardSet.bits, 7), value);
#endif
                }
            }

            double runTime = (DateTime.Now - startTime).TotalSeconds;
            PrintResult(handCount * repCount, runTime, checksum);
        }