1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
6 using Microsoft.Xunit.Performance;
8 using System.Runtime.CompilerServices;
11 [assembly: OptimizeForBenchmarks]
13 namespace Benchstone.BenchF
15 public static class BenchMrk
18 public const int Iterations = 1;
20 public const int Iterations = 4000000;
23 private static int s_i, s_n;
24 private static float s_p, s_a, s_x, s_f, s_e;
26 [MethodImpl(MethodImplOptions.NoInlining)]
27 private static bool Bench()
29 s_p = (float)Math.Acos(-1.0);
33 for (s_i = 1; s_i <= s_n; ++s_i)
37 s_e = (float)(Math.Abs(Math.Log(Math.Exp(s_x)) / s_x) - Math.Sqrt((Math.Sin(s_x) * Math.Sin(s_x)) + Math.Cos(s_x) * Math.Cos(s_x)));
38 s_a = s_a + Math.Abs(s_e);
45 public static void Test()
47 foreach (var iteration in Benchmark.Iterations)
49 using (iteration.StartMeasurement())
56 private static bool TestBase()
58 bool result = Bench();
62 public static int Main()
64 bool result = TestBase();
65 return (result ? 100 : -1);