static void Main() { Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Highest; TestPattern[] testPatters = { #region Normal new TestPattern { Name = "void", Actions = new Action[] { () => TestDllImport.FuncVoid(), () => TestDll.Instance.FuncVoid(), } }, new TestPattern { Name = "void(int)", Actions = new Action[] { () => TestDllImport.FuncVoidInt(1234), () => TestDll.Instance.FuncVoidInt(1234), } }, new TestPattern { Name = "int(string)", Actions = new Action[] { () => TestDllImport.FuncIntString("abc"), () => TestDll.Instance.FuncIntString("abc"), } }, new TestPattern { Name = "bool(int)", Actions = new Action[] { () => TestDllImport.FuncBoolInt(1), () => TestDll.Instance.FuncBoolInt(1), } }, new TestPattern { Name = "bool(string,int)", Actions = new Action[] { () => TestDllImport.FuncBoolStringInt("abc", 1234), () => TestDll.Instance.FuncBoolStringInt("abc", 1234), } }, new TestPattern { Name = "int(string,int,char,int)", Actions = new Action[] { () => TestDllImport.FuncIntArg4("abc", 1234, 'A', 456), () => TestDll.Instance.FuncIntArg4("abc", 1234, 'A', 456), } }, new TestPattern { Name = "void(BigStructure)", Actions = new Action[] { () => TestDllImport.FuncVoidBigStructure(new BigStructure()), () => TestDll.Instance.FuncVoidBigStructure(new BigStructure()), } }, #endregion #region ParamLen new TestPattern { Name = "void(int1)", Actions = new Action[] { () => TestDllImport.FuncVoidInt1(1), () => TestDll.Instance.FuncVoidInt1(1), } }, new TestPattern { Name = "void(int2)", Actions = new Action[] { () => TestDllImport.FuncVoidInt2(1, 2), () => TestDll.Instance.FuncVoidInt2(1, 2), } }, new TestPattern { Name = "void(int3)", Actions = new Action[] { () => TestDllImport.FuncVoidInt3(1, 2, 3), () => TestDll.Instance.FuncVoidInt3(1, 2, 3), } }, new TestPattern { Name = "void(int4)", Actions = new Action[] { () => TestDllImport.FuncVoidInt4(1, 2, 3, 4), () => TestDll.Instance.FuncVoidInt4(1, 2, 3, 4), } }, new TestPattern { Name = "void(int5)", Actions = new Action[] { () => TestDllImport.FuncVoidInt5(1, 2, 3, 4, 5), () => TestDll.Instance.FuncVoidInt5(1, 2, 3, 4, 5), } }, new TestPattern { Name = "void(int6)", Actions = new Action[] { () => TestDllImport.FuncVoidInt6(1, 2, 3, 4, 5, 6), () => TestDll.Instance.FuncVoidInt6(1, 2, 3, 4, 5, 6), } }, new TestPattern { Name = "void(int7)", Actions = new Action[] { () => TestDllImport.FuncVoidInt7(1, 2, 3, 4, 5, 6, 7), () => TestDll.Instance.FuncVoidInt7(1, 2, 3, 4, 5, 6, 7), } }, new TestPattern { Name = "void(int8)", Actions = new Action[] { () => TestDllImport.FuncVoidInt8(1, 2, 3, 4, 5, 6, 7, 8), () => TestDll.Instance.FuncVoidInt8(1, 2, 3, 4, 5, 6, 7, 8), } }, new TestPattern { Name = "void(int9)", Actions = new Action[] { () => TestDllImport.FuncVoidInt9(1, 2, 3, 4, 5, 6, 7, 8, 9), () => TestDll.Instance.FuncVoidInt9(1, 2, 3, 4, 5, 6, 7, 8, 9), } }, new TestPattern { Name = "void(int10)", Actions = new Action[] { () => TestDllImport.FuncVoidInt10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), () => TestDll.Instance.FuncVoidInt10(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), } }, #endregion }; const int TestTimes = 50000000; const int TestAveraging = 5; const bool IgnoreFirst = true; try { for (; ;) { Console.WriteLine("TestTimes:{0}[call/test] Averaging:{1} IgnoreFirstCall:{2}", TestTimes, TestAveraging, IgnoreFirst); foreach (var tp in testPatters) { Test(tp, TestTimes, TestAveraging, IgnoreFirst); } } } catch (Exception ex) { Console.WriteLine(ex.ToString()); Console.ReadLine(); } }
public void FuncVoidInt2(int v1, int v2) { TestDllImport.FuncVoidInt2(v1, v2); }