/** * 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); }
/** * 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 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; }