Пример #1
0
        public static void Test()
        {
            var watch = new Stopwatch();

            watch.Start();

            int testSize = 10000000;
            var uf       = new MyUnionFind();

            uf.Resize(testSize);

            for (int i = 0; i < testSize; ++i)
            {
                uf.Union(i, i >> 1);
            }

            // Check that it works:
            var papa = uf.Find(0);

            //for(int j = 0; j < 10; ++j)
            for (int i = 0; i < testSize; ++i)
            {
                if (papa != uf.Find(i))
                {
                    File.AppendAllText(@"C:\Users\daniel.ilha\Desktop\perf.log", "FAIL!\n");
#if !XB1
                    Environment.Exit(1);
#else // XB1
                    System.Diagnostics.Debug.Assert(false, "XB1 TODO?");
#endif // XB1
                }
            }
            var enlapsed = watch.ElapsedMilliseconds;

            File.AppendAllText(@"C:\Users\daniel.ilha\Desktop\perf.log", string.Format("Test took {0:N}ms\n", enlapsed));
        }
Пример #2
0
        public static void Test()
        {
            var watch = new Stopwatch();
            watch.Start();

            int testSize = 10000000;
            var uf = new MyUnionFind();

            uf.Resize(testSize);

            for (int i = 0; i < testSize; ++i)
            {
                uf.Union(i, i >> 1);
            }

            // Check that it works:
            var papa = uf.Find(0);
            //for(int j = 0; j < 10; ++j)
            for (int i = 0; i < testSize; ++i)
            {
                if (papa != uf.Find(i))
                {
                    File.AppendAllText(@"C:\Users\daniel.ilha\Desktop\perf.log", "FAIL!\n");
                    Environment.Exit(1);
                }
            }
            var enlapsed = watch.ElapsedMilliseconds;

            File.AppendAllText(@"C:\Users\daniel.ilha\Desktop\perf.log", string.Format("Test took {0:N}ms\n", enlapsed));
        }