Skip to content

Latest commit

 

History

History
20 lines (14 loc) · 1.19 KB

File metadata and controls

20 lines (14 loc) · 1.19 KB

Dynamic <-> Reflection <-> Generic Benchmarking

You may find code here: https://github.com/Glareone/Advanced-Csharp-topics/tree/main/dynamic-performance/ConsoleApp1

Dynamic usecases

  • How to use dynamic to call Python code and to build ExpandoObject (dynamic object with dynamic properties);
  • You may find examples with Python Code in PythonAsText project

These examples will let you know whether Dynamic is really slow and if it's true - how much comparing with Reflection and direct allocation or method's call.

  • You may find examples in Dynamic.Performance project

Benchmark results:

  • Methods called directly, using reflection, using dynamic and using dynamic ExpandoObject
    image
    Usually reflection is a bit faster than dynamic method. And it's a bit slower if you pass both parameters to method. Very interesting.
    image

  • Allocation using Generic vs Dynamic
    image