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.BenchI
15 public static class Fib
19 public const int Iterations = 1;
21 public const int Iterations = 3500;
24 const int Number = 24;
26 static int Fibonacci(int x) {
28 return (Fibonacci(x - 1) + Fibonacci(x - 2));
35 [MethodImpl(MethodImplOptions.NoInlining)]
37 int fib = Fibonacci(Number);
38 return (fib == 46368);
42 public static void Test() {
43 foreach (var iteration in Benchmark.Iterations) {
44 using (iteration.StartMeasurement()) {
45 for (int i = 0; i < Iterations; i++) {
52 static bool TestBase() {
54 for (int i = 0; i < Iterations; i++) {
60 public static int Main() {
61 bool result = TestBase();
62 return (result ? 100 : -1);