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 IniArray
19 public const int Iterations = 1;
21 public const int Iterations = 10000000;
24 const int Allotted = 16;
25 static volatile object VolatileObject;
27 static void Escape(object obj) {
31 [MethodImpl(MethodImplOptions.NoInlining)]
33 char[] workarea = new char[Allotted];
34 for (int i = 0; i < Iterations; i++) {
35 for (int j = 0; j < Allotted; j++) {
44 public static void Test() {
45 foreach (var iteration in Benchmark.Iterations) {
46 using (iteration.StartMeasurement()) {
52 static bool TestBase() {
53 bool result = Bench();
57 public static int Main() {
58 bool result = TestBase();
59 return (result ? 100 : -1);