Beispiel #1
0
        static void PrintSeqs()
        {
            Lib.Class1 c = new Lib.Class1();

            foreach (var n in new ulong[] { UInt64.MaxValue, 42, 12297829382473034410, UInt64.MinValue })
            {
                PrintSeq(c.EnumerateSquaresImpl1(n));
                PrintSeq(c.EnumerateSquaresImpl2(n));
                PrintSeq(c.EnumerateSquaresImpl3(n));
                PrintSeq(c.EnumerateSquaresImpl4(n));
            }
        }
Beispiel #2
0
        static void Test(int iterations, ulong value)
        {
            Console.WriteLine("------------------------");
            Console.WriteLine("iterations = {0}, value = {1}", iterations, value);

            int SIZE = iterations;

            List <ulong> xs;

            Lib.Class1 c = new Lib.Class1();

            xs = new List <ulong>(SIZE);
            var t1 = InstrumentedOperation.Test(() =>
            {
                for (int i = 0; i < SIZE; ++i)
                {
                    xs.AddRange(c.EnumerateSquaresImpl1(value));
                }
            }, "EnumerateSquaresImpl1");

            Console.WriteLine(xs.Count);
            Console.WriteLine(t1);

            xs = new List <ulong>();
            var t2 = InstrumentedOperation.Test(() =>
            {
                for (int i = 0; i < SIZE; ++i)
                {
                    xs.AddRange(c.EnumerateSquaresImpl2(value));
                }
            }, "EnumerateSquaresImpl2");

            Console.WriteLine(xs.Count);
            Console.WriteLine(t2);

            xs = new List <ulong>(SIZE);
            var t3 = InstrumentedOperation.Test(() =>
            {
                for (int i = 0; i < SIZE; ++i)
                {
                    xs.AddRange(c.EnumerateSquaresImpl3(value));
                }
            }, "EnumerateSquaresImpl3");

            Console.WriteLine(xs.Count);
            Console.WriteLine(t3);

            xs = new List <ulong>(SIZE);
            var t4 = InstrumentedOperation.Test(() =>
            {
                for (int i = 0; i < SIZE; ++i)
                {
                    xs.AddRange(c.EnumerateSquaresImpl4(value));
                }
            }, "EnumerateSquaresImpl4");

            Console.WriteLine(xs.Count);
            Console.WriteLine(t4);

            Console.WriteLine("------------------------");
        }