BenchmarkDotNet=v0.10.14, OS=Windows 10.0.17134
Intel Core i5-4430 CPU 3.00GHz (Haswell), 1 CPU, 4 logical and 4 physical cores
Frequency=2929696 Hz, Resolution=341.3323 ns, Timer=TSC
.NET Core SDK=2.1.300
[Host] : .NET Core 2.0.7 (CoreCLR 4.6.26328.01, CoreFX 4.6.26403.03), 64bit RyuJIT DEBUG
DefaultJob : .NET Core 2.0.7 (CoreCLR 4.6.26328.01, CoreFX 4.6.26403.03), 64bit RyuJIT
Method |
Mean |
Error |
StdDev |
Scaled |
Allocated |
Direct_call |
661.7 us |
6.213 us |
5.812 us |
1.00 |
0 B |
Call_lambda |
665.5 us |
7.528 us |
7.042 us |
1.01 |
0 B |
Call_struct_lambda |
660.0 us |
2.248 us |
2.103 us |
1.00 |
0 B |
Take a look at the generated IL for each test case, and also the generated JIT code (benchmarkdotnet now has asm diagnostics now). The F# compiler automatically inline small functions and methods (related issue: dotnet/fsharp#5178). The C# (afaik) will not inline automatically, but you can hint the JIT to inline it in generated code with AgressiveInlining flags.