public static int test_0_constrained_normal_call() { IFaceConstrained c = new ClassConstrained(); var o = new VClass(); var res = c.constrained_normal_call <int, VClass> (1, o); return(res == o ? 0 : 1); }
public static void TestVClass() { var vClass = new VClass <VCase>(); Console.WriteLine(vClass.ToString()); }
public void CallPerformanceTest() { const int N = 10000000; for (int repeat = 3; repeat != 0; --repeat) { Console.WriteLine("element count = {0}", N); Console.WriteLine(); VClass inst = new DClass(); VClass baseInst = new VClass(); ITestContract contr = new TestConforming(); int y = 456; var r1 = inst.VirtMethod1(y); var r2 = inst.ThisMethod1(y); var r3 = VClass.StaticMethod1(y); var r4 = inst.VirtFact(5); var r5 = inst.ThisFact(5); var r6 = VClass.StaticFact(5); var r7 = baseInst.VirtFact(5); var r8 = contr.MethodImplicit(y); var r9 = contr.MethodExplicit(y); var r10 = contr.FactExplicit(5); var r11 = contr.FactImplicit(5); var timer = new Stopwatch(); timer.Start(); for (int i = N; i != 0; --i) { } timer.Stop(); TimeSpan dryRun = timer.Elapsed; { timer.Reset(); timer.Start(); for (int i = N; i != 0; --i) { int r = inst.VirtMethod1(y); } timer.Stop(); TimeSpan t = (timer.Elapsed - dryRun); Console.WriteLine("virt calls : {0}", t); } { timer.Reset(); timer.Start(); for (int i = N; i != 0; --i) { int r = inst.ThisMethod1(y); } timer.Stop(); TimeSpan t = (timer.Elapsed - dryRun); Console.WriteLine("this calls : {0}", t); } { timer.Reset(); timer.Start(); for (int i = N; i != 0; --i) { int r = VClass.StaticMethod1(y); } timer.Stop(); TimeSpan t = (timer.Elapsed - dryRun); Console.WriteLine("static calls : {0}", t); } int factArg = 10; { timer.Reset(); timer.Start(); for (int i = N; i != 0; --i) { int r = inst.VirtFact(factArg); } timer.Stop(); TimeSpan t = (timer.Elapsed - dryRun); Console.WriteLine("derived virt fact : {0}", t); } { timer.Reset(); timer.Start(); for (int i = N; i != 0; --i) { int r = baseInst.VirtFact(factArg); } timer.Stop(); TimeSpan t = (timer.Elapsed - dryRun); Console.WriteLine("base virt fact : {0}", t); } { timer.Reset(); timer.Start(); for (int i = N; i != 0; --i) { int r = inst.ThisFact(factArg); } timer.Stop(); TimeSpan t = (timer.Elapsed - dryRun); Console.WriteLine("this fact : {0}", t); } { timer.Reset(); timer.Start(); for (int i = N; i != 0; --i) { int r = VClass.StaticFact(factArg); } timer.Stop(); TimeSpan t = (timer.Elapsed - dryRun); Console.WriteLine("static fact : {0}", t); } } }
public void CallPerformanceTest() { const int N = 10000000; for (int repeat = 3; repeat != 0; --repeat) { Console.WriteLine("element count = {0}", N); Console.WriteLine(); VClass inst = new DClass(); VClass baseInst = new VClass(); ITestContract contr = new TestConforming(); int y = 456; var r1 = inst.VirtMethod1(y); var r2 = inst.ThisMethod1(y); var r3 = VClass.StaticMethod1(y); var r4 = inst.VirtFact(5); var r5 = inst.ThisFact(5); var r6 = VClass.StaticFact(5); var r7 = baseInst.VirtFact(5); var r8 = contr.MethodImplicit(y); var r9 = contr.MethodExplicit(y); var r10 = contr.FactExplicit(5); var r11 = contr.FactImplicit(5); var timer = new Stopwatch(); timer.Start(); for (int i = N; i != 0; --i) { } timer.Stop(); TimeSpan dryRun = timer.Elapsed; { timer.Reset(); timer.Start(); for (int i = N; i != 0; --i) { int r = inst.VirtMethod1(y); } timer.Stop(); TimeSpan t = (timer.Elapsed - dryRun); Console.WriteLine("virt calls : {0}", t); } { timer.Reset(); timer.Start(); for (int i = N; i != 0; --i) { int r = inst.ThisMethod1(y); } timer.Stop(); TimeSpan t = (timer.Elapsed - dryRun); Console.WriteLine("this calls : {0}", t); } { timer.Reset(); timer.Start(); for (int i = N; i != 0; --i) { int r = VClass.StaticMethod1(y); } timer.Stop(); TimeSpan t = (timer.Elapsed - dryRun); Console.WriteLine("static calls : {0}", t); } int factArg = 10; { timer.Reset(); timer.Start(); for (int i = N; i != 0; --i) { int r = inst.VirtFact(factArg); } timer.Stop(); TimeSpan t = (timer.Elapsed - dryRun); Console.WriteLine("derived virt fact : {0}", t); } { timer.Reset(); timer.Start(); for (int i = N; i != 0; --i) { int r = baseInst.VirtFact(factArg); } timer.Stop(); TimeSpan t = (timer.Elapsed - dryRun); Console.WriteLine("base virt fact : {0}", t); } { timer.Reset(); timer.Start(); for (int i = N; i != 0; --i) { int r = inst.ThisFact(factArg); } timer.Stop(); TimeSpan t = (timer.Elapsed - dryRun); Console.WriteLine("this fact : {0}", t); } { timer.Reset(); timer.Start(); for (int i = N; i != 0; --i) { int r = VClass.StaticFact(factArg); } timer.Stop(); TimeSpan t = (timer.Elapsed - dryRun); Console.WriteLine("static fact : {0}", t); } } }