Open
Description
Here is simplified benchmark on .NET Core, but I have similar results on Full CLR:
[DisassemblyDiagnoser(recursiveDepth: 100)]
public class CallDelegate
{
private static readonly Func<string> _showTime = () => "Now is: " + DateTime.Now;
[Benchmark(Baseline = true)]
public object Direct() => "Now is: " + DateTime.Now;
[Benchmark]
public object CallFunc() => _showTime();
}
Here is the results:
Here is the asm CallDelegate_CallFunc_DefaultJob-asm.raw.html
00007ffb`7f260e10 FastExpressionCompiler.Benchmarks.Program+CallDelegate.CallFunc()
00007ffb`7f260e14 48b928162d7ffb7f0000 mov rcx,7FFB7F2D1628h
00007ffb`7f260e1e ba2d000000 mov edx,2Dh
00007ffb`7f260e23 e82846ad5f call coreclr!MetaDataGetDispenser+0x73970 (00007ffb`ded35450) not managed method
00007ffb`7f260e28 48b9586d45725e020000 mov rcx,25E72456D58h
00007ffb`7f260e32 488b01 mov rax,qword ptr [rcx]
00007ffb`7f260e35 488b4808 mov rcx,qword ptr [rax+8]
00007ffb`7f260e39 488b4018 mov rax,qword ptr [rax+18h]
The asm for Direct
benchmark is a very long (recursiveDepth: 100
)
BTW, My original benchmark target was https://github.com/dadhi/FastExpressionCompiler/blob/master/test/FastExpressionCompiler.Benchmarks/SimpleExpr_ParamPlusParam.cs