예제 #1
0
 private static unsafe void Abc(string str)
 {
     fixed(char *p = str)
     {
         TestDllImport.FuncIntStringPtr((IntPtr)p);
     }
 }
예제 #2
0
 public void FuncVoidInt7(int v1, int v2, int v3, int v4, int v5, int v6, int v7)
 {
     TestDllImport.FuncVoidInt7(v1, v2, v3, v4, v5, v6, v7);
 }
예제 #3
0
 public void FuncVoidInt6(int v1, int v2, int v3, int v4, int v5, int v6)
 {
     TestDllImport.FuncVoidInt6(v1, v2, v3, v4, v5, v6);
 }
예제 #4
0
 public void FuncVoidInt5(int v1, int v2, int v3, int v4, int v5)
 {
     TestDllImport.FuncVoidInt5(v1, v2, v3, v4, v5);
 }
예제 #5
0
 public void FuncVoidInt4(int v1, int v2, int v3, int v4)
 {
     TestDllImport.FuncVoidInt4(v1, v2, v3, v4);
 }
예제 #6
0
 public void FuncVoidInt3(int v1, int v2, int v3)
 {
     TestDllImport.FuncVoidInt3(v1, v2, v3);
 }
예제 #7
0
 public void FuncVoid()
 {
     TestDllImport.FuncVoid();
 }
예제 #8
0
 public void FuncVoidBigStructure(BigStructure bs)
 {
     TestDllImport.FuncVoidBigStructure(bs);
 }
예제 #9
0
 public int FuncIntArg4(string abc, int xyz, char c, int val)
 {
     return(TestDllImport.FuncIntArg4(abc, xyz, c, val));
 }
예제 #10
0
 public int FuncStrCount(string abc)
 {
     return(TestDllImport.FuncStrCount(abc));
 }
예제 #11
0
 public bool FuncBoolStringInt(string abc, int xyz)
 {
     return(TestDllImport.FuncBoolStringInt(abc, xyz));
 }
예제 #12
0
 public int FuncIntString(string str)
 {
     return(TestDllImport.FuncIntString(str));
 }
예제 #13
0
 public bool FuncBoolInt(int i)
 {
     return(TestDllImport.FuncBoolInt(i));
 }
예제 #14
0
 public void FuncVoidInt(int i)
 {
     TestDllImport.FuncVoidInt(i);
 }
예제 #15
0
 public void FuncVoidInt8(int v1, int v2, int v3, int v4, int v5, int v6, int v7, int v8)
 {
     TestDllImport.FuncVoidInt8(v1, v2, v3, v4, v5, v6, v7, v8);
 }
예제 #16
0
 public void FuncVoidInt10(int v1, int v2, int v3, int v4, int v5, int v6, int v7, int v8, int v9, int v10)
 {
     TestDllImport.FuncVoidInt10(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10);
 }
예제 #17
0
 public void FuncVoidInt1(int v1)
 {
     TestDllImport.FuncVoidInt1(v1);
 }
예제 #18
0
        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();
            }
        }
예제 #19
0
 public void FuncVoidInt2(int v1, int v2)
 {
     TestDllImport.FuncVoidInt2(v1, v2);
 }