/** * testCreationOfString */ public static long testSetterGetterClassWith1String() { ClassWith1StringGetterSetter classWith1String = new ClassWith1StringGetterSetter(); int count = 0; string string1 = "string1"; string string2 = "string2"; DateTime start = DateTime.Now; for (int i = NB_SETTER_GETTER_STRING_TESTS; i-- != 0;) { // Write to force jre not to optimize the code if (i % 2 == 0) { classWith1String.String1 = string1; } else { classWith1String.String1 = string2; } count += classWith1String.String1.Length; } DateTime end = DateTime.Now; TimeSpan executionTime = end - start; Console.WriteLine("[GetterSetterTest], Setter Getter of ClassWith1String() test=" + NB_SETTER_GETTER_STRING_TESTS + ",count=" + count + " classWith1String.String1=" + classWith1String.String1 + ", snapshot time," + executionTime.TotalMilliseconds); return((long)executionTime.TotalMilliseconds); }
/** * testCreationOfString */ public static long testSetterClassWith1String() { ClassWith1StringGetterSetter classWith1String = new ClassWith1StringGetterSetter(); string string1 = "string1"; string string2 = "string2"; DateTime start = DateTime.Now; for (int i = NB_SETTER_GETTER_STRING_TESTS; i-- != 0; ) { // Write to force jre not to optimize the code if (i % 2 == 0) { classWith1String.String1 = string1; } else { classWith1String.String1 = string2; } } DateTime end = DateTime.Now; TimeSpan executionTime = end - start; Console.WriteLine("[GetterSetterTest], Setter of ClassWith1String() test=" + NB_SETTER_GETTER_STRING_TESTS + ", classWith1String.String1=" + classWith1String.String1 + ", snapshot time," + executionTime.TotalMilliseconds); return (long)executionTime.TotalMilliseconds; }
/** * testCreationOfString */ public static long testGetterClassWith1String() { ClassWith1StringGetterSetter classWith1String = new ClassWith1StringGetterSetter(); int count = 0; DateTime start = DateTime.Now; for (int i = NB_SETTER_GETTER_STRING_TESTS; i-- != 0; ) { // Write to force cpp not to optimize the code, never executed if (i % 2 == 2) { classWith1String.String1 = "s1"; } count += classWith1String.String1.Length; } DateTime end = DateTime.Now; TimeSpan executionTime = end - start; Console.WriteLine("[GetterSetterTest], Getter of ClassWith1String() test=" + NB_SETTER_GETTER_STRING_TESTS + ", count=" + count + " classWith1String.String1=" + classWith1String.String1 + ", snapshot time," + executionTime.TotalMilliseconds); return (long)executionTime.TotalMilliseconds; }