public void Vector2DistanceSquaredTest() { Vector2 a = new Vector2(1.0f, 2.0f); Vector2 b = new Vector2(3.0f, 4.0f); Single expected = 8.0f; Single actual; actual = Vector2.DistanceSquared(a, b); Assert.True(MathHelper.Equal(expected, actual), "Vector2f.DistanceSquared did not return the expected value."); }
public static Single DistanceSquaredJitOptimizeCanaryTest() { Single result = 0.0f; var value = VectorTests.Vector2Value; for (var iteration = 0; iteration < Benchmark.InnerIterationCount; iteration++) { value += VectorTests.Vector2Delta; result += Vector2.DistanceSquared(value, VectorTests.Vector2ValueInverted); } return(result); }
public static Single DistanceSquaredTest() { 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.DistanceSquared(VectorTests.Vector2Value, VectorTests.Vector2ValueInverted); } return(result); }