[IterationCount(10)] [InvocationCount(100_000_000)] public class Bench22 { Random rnd = new Random(); private int x; public int X { get { return rnd.Next(1, 5); } } [Benchmark] [Arguments(1)] [Arguments(2)] [Arguments(3)] [Arguments(4)] public int CSharp(int s) { return Cond(s); } [Benchmark] [Arguments(1)] [Arguments(2)] [Arguments(3)] [Arguments(4)] public int FSharp(int s) { return FSTest.Bench.condition(s); } // // FSharp will not inline the code so we shouldn't eiter. // [MethodImpl(MethodImplOptions.NoInlining)] public static int Cond(int x) { if (x == 1 || x == 2) return 1; else if (x == 3 || x == 4) return 2; else return 0; } } //// FS CODE // // /* namespace FSTest module Bench = let condition x = if (x = 1 || x = 2) then 1 elif(x = 3 || x = 4) then 2 else 0 */