public static void Validate()
        {
            var instance = new PerformanceTests();

            instance.GlobalSetup();

            instance.SoAOneByOne();
            var firstOutput = instance._xsCopy.Zip(instance._ysCopy, (x, y) => (x, y)).ToArray();

            for (int i = 0; i < firstOutput.Length; i++)
            {
                if (firstOutput[i].Equals((instance._xys[i].X, instance._xys[i].Y)))
                {
                    throw new Exception("Validation failure: transformer isn't actually transforming.");
                }
            }

            instance.SoABatched();
            Validate(instance._xsCopy.Zip(instance._ysCopy, (x, y) => (x, y)).ToArray());

            instance.TightAoSOneByOne();
            Validate(Array.ConvertAll(instance._xysCopy, xy => (xy.X, xy.Y)));

            instance.TightAoSBatched();
            Validate(Array.ConvertAll(instance._xysCopy, xy => (xy.X, xy.Y)));

            instance.LooserAoSOneByOne();
            Validate(Array.ConvertAll(instance._xyzsCopy, xyz => (xyz.X, xyz.Y)));

            instance.LooserAoSBatched();
            Validate(Array.ConvertAll(instance._xyzsCopy, xyz => (xyz.X, xyz.Y)));

            void Validate(ReadOnlySpan <(double x, double y)> nextOutput)
            {
                if (!nextOutput.SequenceEqual(firstOutput))
                {
                    throw new Exception("Validation failure: some transform method is giving different results than another.");
                }
            }
        }
Exemple #2
0
 static void Main()
 {
     PerformanceTests.Validate();
     BenchmarkRunner.Run <PerformanceTests>();
 }