public void Vector2DistanceTest2() { Vector2 a = new Vector2(1.051f, 2.05f); Vector2 b = new Vector2(1.051f, 2.05f); Single actual = Vector2.Distance(a, b); Assert.Equal(0.0f, actual); }
public void Vector2DistanceTest() { Vector2 a = new Vector2(1.0f, 2.0f); Vector2 b = new Vector2(3.0f, 4.0f); Single expected = (Single)System.Math.Sqrt(8); Single actual; actual = Vector2.Distance(a, b); Assert.True(MathHelper.Equal(expected, actual), "Vector2f.Distance did not return the expected value."); }
public static Single DistanceJitOptimizeCanaryTest() { Single result = 0.0f; var value = VectorTests.Vector2Value; for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) { value += VectorTests.Vector2Delta; result += Vector2.Distance(value, VectorTests.Vector2ValueInverted); } return(result); }
public static Single DistanceTest() { Single result = 0.0f; for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) { // The inputs aren't being changed and the output is being reset with each iteration, so a future // optimization could potentially throw away everything except for the final call. This would break // the perf test. The JitOptimizeCanary code below does modify the inputs and consume each output. result = Vector2.Distance(VectorTests.Vector2Value, VectorTests.Vector2ValueInverted); } return(result); }