static long Payload(int iterations, int length, IComparing comparer) { byte[] array1 = new byte[length]; byte[] array2 = new byte[length]; //check that compare is actually working. if (comparer.Compare(array1, array2) == false) { throw new ApplicationException(comparer.GetType().Name + " returned false where arrays are equal"); } array2[length - 1] = 1; if (comparer.Compare(array1, array2) == true) { throw new ApplicationException(comparer.GetType().Name + " returned true where arrays are not equal"); } array2[length - 1] = 0; Stopwatch sw = Stopwatch.StartNew(); for (var i = 0; i < iterations; i++) { comparer.Compare(array1, array2); } return(sw.ElapsedMilliseconds); }
static long Payload(int iterations, int length, IComparing comparer) { byte[] array1 = new byte[length]; byte[] array2 = new byte[length]; //check that compare is actually working. if (comparer.Compare(array1, array2) == false) throw new ApplicationException(comparer.GetType().Name + " returned false where arrays are equal"); array2[length - 1] = 1; if (comparer.Compare(array1, array2) == true) throw new ApplicationException(comparer.GetType().Name + " returned true where arrays are not equal"); array2[length - 1] = 0; Stopwatch sw = Stopwatch.StartNew(); for (var i = 0; i < iterations;i++) comparer.Compare(array1, array2); return sw.ElapsedMilliseconds; }