/** * testCreationOfString */ public static long testGetterReflectionClassWith1StringWithReflection() { int count = 0; object[] arguments = new object [] {}; ReflectionClassWith1String reflectionClassWith1String = new ReflectionClassWith1String(); Type type = reflectionClassWith1String.GetType(); DateTime start = DateTime.Now; for (int i = NB_GETTER_TESTS; i != 0; i--) { String s = (String)type.InvokeMember("String1", BindingFlags.Default | BindingFlags.GetProperty, null, reflectionClassWith1String, arguments); count = count + s.Length; } DateTime end = DateTime.Now; TimeSpan executionTime = end - start; Console.WriteLine("[ReflectionTest], Getter of ReflectionClassWith1String() with Reflection test=" + NB_GETTER_TESTS + ", count=" + count + ", snapshot time," + executionTime.TotalMilliseconds); return((long)executionTime.TotalMilliseconds); }
/** * testInvokeOfAnInstanceMethodWithSetInstanceVariableWithoutInterface. * * @return */ public static long testCreationReflectionClassWith1String() { int count = 0; DateTime start = DateTime.Now; for (int i = NB_CREATION_TESTS; i != 0; i--) { ReflectionClassWith1String s = new ReflectionClassWith1String(); count = count + s.String1.Length; } DateTime end = DateTime.Now; TimeSpan executionTime = end - start; Console.WriteLine("[ReflectionTest], Creation of ReflectionClassWith1String " + NB_CREATION_TESTS + ", count=" + count + ", snapshot time," + executionTime.TotalMilliseconds); return((long)executionTime.TotalMilliseconds); }
/** * testCreationOfString */ public static long testSetterReflectionClassWith1String() { ReflectionClassWith1String classWith1String = new ReflectionClassWith1String(); int count = 0; DateTime start = DateTime.Now; for (int i = NB_SETTER_TESTS; i != 0; i--) { classWith1String.String1 = "string1"; } DateTime end = DateTime.Now; TimeSpan executionTime = end - start; Console.WriteLine("[ReflectionTest], Setter of ReflectionClassWith1String() test=" + NB_GETTER_TESTS + ", count=" + count + ", snapshot time," + executionTime.TotalMilliseconds); return((long)executionTime.TotalMilliseconds); }
/** * testInvokeOfAnInstanceMethodWithSetInstanceVariableWithoutInterface. * * @return */ public static long testCreationReflectionClassWith1StringWithReflection() { int count = 0; Type type = Type.GetType( "ReflectionClassWith1String"); DateTime start = DateTime.Now; for (int i = NB_CREATION_TESTS; i != 0; i--) { ReflectionClassWith1String s = (ReflectionClassWith1String)Activator.CreateInstance(type); count = count + s.String1.Length; } DateTime end = DateTime.Now; TimeSpan executionTime = end - start; Console.WriteLine("[ReflectionTest], Creation of ReflectionClassWith1String With Reflection " + NB_CREATION_TESTS + ", count=" + count + ", snapshot time," + executionTime.TotalMilliseconds); return((long)executionTime.TotalMilliseconds); }
/** * testCreationOfString */ public static long testSetterReflectionClassWith1StringWithReflection() { ReflectionClassWith1String reflectionClassWith1String = new ReflectionClassWith1String(); object[] arguments = new object[] { "string1" }; DateTime start = DateTime.Now; for (int i = NB_SETTER_TESTS; i != 0; i--) { reflectionClassWith1String.GetType().InvokeMember("String1", BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty, null, reflectionClassWith1String, arguments); } DateTime end = DateTime.Now; TimeSpan executionTime = end - start; Console.WriteLine("[ReflectionTest], Setter of ReflectionClassWith1String() with Reflection test=" + NB_GETTER_TESTS + ", snapshot time,," + executionTime.TotalMilliseconds); return((long)executionTime.TotalMilliseconds); }
/** * testCreationOfString */ public static long testSetterReflectionClassWith1StringWithReflection() { ReflectionClassWith1String reflectionClassWith1String = new ReflectionClassWith1String(); object[] arguments = new object[] { "string1"}; DateTime start = DateTime.Now; for (int i = NB_SETTER_TESTS; i != 0; i--) { reflectionClassWith1String.GetType().InvokeMember("String1", BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty, null, reflectionClassWith1String, arguments); } DateTime end = DateTime.Now; TimeSpan executionTime = end - start; Console.WriteLine("[ReflectionTest], Setter of ReflectionClassWith1String() with Reflection test=" + NB_GETTER_TESTS + ", snapshot time,," + executionTime.TotalMilliseconds); return (long)executionTime.TotalMilliseconds; }
/** * testCreationOfString */ public static long testSetterReflectionClassWith1String() { ReflectionClassWith1String classWith1String = new ReflectionClassWith1String(); int count = 0; DateTime start = DateTime.Now; for (int i = NB_SETTER_TESTS; i != 0; i--) { classWith1String.String1 = "string1"; } DateTime end = DateTime.Now; TimeSpan executionTime = end - start; Console.WriteLine("[ReflectionTest], Setter of ReflectionClassWith1String() test=" + NB_GETTER_TESTS + ", count=" + count + ", snapshot time," + executionTime.TotalMilliseconds); return (long)executionTime.TotalMilliseconds; }
/** * testCreationOfString */ public static long testGetterReflectionClassWith1StringWithReflection() { int count = 0; object[] arguments = new object [] {}; ReflectionClassWith1String reflectionClassWith1String = new ReflectionClassWith1String(); Type type = reflectionClassWith1String.GetType(); DateTime start = DateTime.Now; for (int i = NB_GETTER_TESTS; i != 0; i--) { String s = (String)type.InvokeMember("String1", BindingFlags.Default | BindingFlags.GetProperty, null, reflectionClassWith1String, arguments); count = count + s.Length; } DateTime end = DateTime.Now; TimeSpan executionTime = end - start; Console.WriteLine("[ReflectionTest], Getter of ReflectionClassWith1String() with Reflection test=" + NB_GETTER_TESTS + ", count=" + count + ", snapshot time," + executionTime.TotalMilliseconds); return (long) executionTime.TotalMilliseconds; }
/** * testInvokeOfAnInstanceMethodWithSetInstanceVariableWithoutInterface. * * @return */ public static long testCreationReflectionClassWith1String() { int count = 0; DateTime start = DateTime.Now; for (int i = NB_CREATION_TESTS; i != 0; i--) { ReflectionClassWith1String s = new ReflectionClassWith1String(); count = count + s.String1.Length; } DateTime end = DateTime.Now; TimeSpan executionTime = end - start; Console.WriteLine("[ReflectionTest], Creation of ReflectionClassWith1String " + NB_CREATION_TESTS + ", count=" + count + ", snapshot time," + executionTime.TotalMilliseconds); return (long)executionTime.TotalMilliseconds; }