public class Program { public static void Main(string[] args) { new BenchmarkRunner().RunCompetition(new IL_Loops()); } } public class IL_Loops { [Params(1, 5, 10, 100)] int MaxCounter = 0; private int[] initialValuesArray; [Setup] public void SetupData() { initialValuesArray = Enumerable.Range(0, MaxCounter).ToArray(); } [Benchmark] public int ForLoop() { var counter = 0; for (int i = 0; i < initialValuesArray.Length; i++) counter += initialValuesArray[i]; return counter; } [Benchmark] public int ForEachArray() { var counter = 0; foreach (var i in initialValuesArray) counter += i; return counter; } } Result: // ***** Competition: Start ***** // Found benchmarks: // IL_Loops_ForEachArray_Throughput_HostPlatform_HostJit_NET-HostFramework -w=5 -t=10 // IL_Loops_ForLoop_Throughput_HostPlatform_HostJit_NET-HostFramework -w=5 -t=10 // ************************** // Benchmark: IL_Loops_ForEachArray (Throughput_HostPlatform_HostJit_NET-HostFramework) [-w=5 -t=10] // Generated project: C:\windows\system32\IL_Loops_ForEachArray_Throughput_HostPlatform_HostJit_NET-HostFramework // Build: // Program.cs(7,7): error CS1001: Identifier expected // OverallResult = Failure // ************************** // Benchmark: IL_Loops_ForLoop (Throughput_HostPlatform_HostJit_NET-HostFramework) [-w=5 -t=10] // Generated project: C:\windows\system32\IL_Loops_ForLoop_Throughput_HostPlatform_HostJit_NET-HostFramework // Build: // Program.cs(7,7): error CS1001: Identifier expected // OverallResult = Failure // ***** Competition: Finish ***** ```ini BenchmarkDotNet=v0.7.8.0 OS=Microsoft Windows NT 6.1.7601 Service Pack 1 Processor=Intel(R) Core(TM) i7-4600U CPU @ 2.10GHz, ProcessorCount=4 HostCLR=MS.NET 4.0.30319.42000, Arch=32-bit 6InvalidOperationException4 Sequence contains no elements