Today, I benchmark dynamic, emit, orgin, and reflect. I was surprised to find that their performance had been greatly improved. My last test results showed that there was still a big performance gap between native and dynamic invocations. I've been looking at the dynamic performance of. Net Core, and I haven't seen any of this in the relevant articles. My question is whether these test results are reliable and when was the performance improved?
Here is the result on different client:
PC1 :
PC2 :
PC3 :

It'll be easier for people to comment on this issue if you post the full code to your benchmarks, either paste them into the issue or link to a gist or similar.
@mattwarren OK . I have upload the code. https://github.com/NMSAzulX/BechmarkReflector
Here is the major code.
```C#
[Benchmark]
public void Origin()
{
TestBechmark instance = new TestBechmark();
instance.Name = "123456789";
}
[Benchmark]
public void Dynamic()
{
TestBechmark instance = new TestBechmark();
RunDynamic(instance);
}
[Benchmark]
public void Reflect()
{
TestBechmark instance = new TestBechmark();
NameInfo.SetValue(instance, "123456789");
}
[Benchmark]
public void Emit()
{
TestBechmark instance = new TestBechmark();
EmitSetString(instance, "123456789");
}
public void RunDynamic(dynamic instance)
{
instance.Name = "123456789";
}
```
cc @jkotas may know.
@NMSAzulX Benchmark.NET should be generating a markdown file for you that can be pasted into the Github issue. Easier to read and search than a screenshot. 馃樃
The dynamic keyword runs a lot of code underneath, and so you will see improvements it its performance as the core capabilities (e.g. code quality or more primitive framework APIs) are improved.
Also, some of your benchmarks above are dominated by object allocation performance. They are not really testing dynamic or Reflection.Emit.
@jkotas @danmosemsft Thank you! :)
And @jkotas Is there any official code for dynamic performance testing? I want to learn it.
https://github.com/dotnet/performance repo has all our performance microbenchmarks. I do not see any microbenchmarks for dynamic keyword there. If you would like to contribute some, PRs are welcomed.
@jkotas Thanks. OK.
Is there any official code for dynamic performance testing? I want to learn it.
@NMSAzulX It's not code, but you might also want to have a read of Microbenchmark Design Guidelines that @adamsitnik just published.
@mattwarren Thanks very much! :)
Most helpful comment
@NMSAzulX It's not code, but you might also want to have a read of Microbenchmark Design Guidelines that @adamsitnik just published.