jemalloc.NET icon indicating copy to clipboard operation
jemalloc.NET copied to clipboard

Validate values computed for JEM buffers during benchmark

Open allisterb opened this issue 8 years ago • 1 comments

General design for a benchmark run over an array/buffer should be:

  1. Compute the baseline value using builtin .NET operators and methods from System.Math.
  2. Compute the value using JEM methods.
  3. In the cleanup phase after each benchmark iteration compare the JEM/builitin values for each element in the array and throw an exception if any don't match.

allisterb avatar Dec 15 '17 10:12 allisterb

Added in 88c3c2b73430b6ba910512f5776c387bd2b0dd45. e.g for validating the array multiply benchmark:

            int index = GM<T>.Rng.Next(0, ArraySize);
            SafeArray<T> nativeArray = GetValue<SafeArray<T>>("nativeArray");
            T[] managedArray = GetValue<T[]>("managedArray");
            T mul = GetValue<T>("mul");
            T fill = GetValue<T>("fill");
            T val = GM<T>.Multiply(fill, mul);
            if (!nativeArray[index].Equals(val))
            {
                Log.WriteLineError($"Native array at index {index} is {nativeArray[index]} not {val}.");
                throw new Exception();
            }
            else if (!managedArray[index].Equals(val))
            {
                Log.WriteLineError($"Managed array at index {index} is {managedArray[index]} not {val}.");
                throw new Exception();
            }

allisterb avatar Dec 17 '17 13:12 allisterb