Пример #1
0
        public void PerformanceTestStructVsClassMethod(UInt32 runCount)
        {
            long before;

            XYClass  c = new XYClass();
            XYStruct s = new XYStruct();

            //
            // Run once to jit the code
            //
            c.TestMe();
            s.TestMe();

            for (UInt32 run = 0; run < runCount; run++)
            {
                Console.WriteLine("Run {0}", run);

                before = Stopwatch.GetTimestamp();
                for (int i = 0; i < 10000000; i++)
                {
                    c.TestMe();
                }
                Console.WriteLine("Class: " + (Stopwatch.GetTimestamp() - before).StopwatchTicksAsDoubleMilliseconds());
                PrintGC("Class");


                before = Stopwatch.GetTimestamp();
                for (int i = 0; i < 10000000; i++)
                {
                    s.TestMe();
                }
                Console.WriteLine("Struct: " + (Stopwatch.GetTimestamp() - before).StopwatchTicksAsDoubleMilliseconds());
                PrintGC("Struct");
            }
        }
Пример #2
0
 void ReadVariables(XYClass c)
 {
     Int32 x = c.a;
     Int32 y = c.b;
 }
Пример #3
0
 XYClass ReturnMe(XYClass c)
 {
     return(c);
 }