Esempio n. 1
0
        public void SolveTest_StressTest()
        {
            Q1NaiveMaxPairWise q1NaiveMaxPairWise = new Q1NaiveMaxPairWise("TD1");
            Q2FastMaxPairWise  q2FastMaxPairWise  = new Q2FastMaxPairWise("TD2");
            Stopwatch          stopwatch          = Stopwatch.StartNew();

            while (true)
            {
                Random rnd = new Random();
                int    n   = rnd.Next(1, 10);
                int    m   = rnd.Next(1, 10);
                long[] arr = new long[n];
                for (int i = 0; i < arr.Length; i++)
                {
                    arr[i] = rnd.Next(1, m);
                }
                long result1 = q1NaiveMaxPairWise.Solve(arr);
                long result2 = q2FastMaxPairWise.Solve(arr);
                Assert.AreEqual(result1, result2);
                if (stopwatch.ElapsedMilliseconds >= 5000)
                {
                    break;
                }
            }
        }
Esempio n. 2
0
        public void SolveTest_StressTest()
        {
            var       Q1   = new Q1NaiveMaxPairWise("TD2");
            var       Q2   = new Q2FastMaxPairWise("TD2");
            Stopwatch time = new Stopwatch();

            time.Start();
            while (time.ElapsedMilliseconds < 5000)
            {
                var array = RandomTests();
                Assert.AreEqual(Q1.Solve(array), Q2.Solve(array));
            }
        }