public static long BenchmarkAccessWithTemps(int tries) { TryEntry <object, object>[] value = new TryEntry <object, object> [iterations]; for (int i = 0; i < iterations; i++) { value[i].Hash = 18; value[i].Key = new object(); value[i].Value = new object(); } int count = 0; var fast = Stopwatch.StartNew(); for (int @try = 0; @try < tries; @try++) { for (int i = 0; i < iterations; i++) { TryEntry <object, object> tmp = value[i]; if (tmp.Hash == 18 && tmp.Key != null && tmp.Value == null) { count++; } } } fast.Stop(); return(fast.ElapsedTicks); }
public static long BenchmarkAccessWithInlineRef(int tries) { TryEntry <object, object>[] value = new TryEntry <object, object> [iterations]; for (int i = 0; i < iterations; i++) { value[i].Hash = 18; value[i].Key = new object(); value[i].Value = new object(); } int count = 0; var fast = Stopwatch.StartNew(); for (int @try = 0; @try < tries; @try++) { for (int i = 0; i < iterations; i++) { if (Check(ref value[i])) { count++; } } } fast.Stop(); return(fast.ElapsedTicks); }
public static long BenchmarkCreationOfArrayOfStructs() { var fast = Stopwatch.StartNew(); TryEntry <object, object>[] value; for (int i = 1; i < iterations; i++) { value = new TryEntry <object, object> [iterations]; value[0].Hash = 18; value[0].Key = new object(); value[0].Value = new object(); } fast.Stop(); return(fast.ElapsedMilliseconds); }
private static bool Check(ref TryEntry <object, object> tmp) { return(tmp.Hash == 18 && tmp.Key != null && tmp.Value == null); }