Tag: Test
-
C# Dynamic Object Creation Performance
Recently I had to task to create a dynamic object creation factory in C#. So I thought I test all the options I have to check what performs best.
I also wanted to check the performance implications these options have with the number of parameters in the constructor.
The Options
- new T() – Using the new/constructor method to
instantiate objects - Activator.CreateInstance(typeof(T)) – Using the Activator class to instantiate objects
- ConstructorInfo.Invoke() – Using the constructor info reflection class to instantiate objects
- Func<T>() – Using compiled lambda expressions to instantiate objects
The Test
I ran some tests to see calculate how each …
- new T() – Using the new/constructor method to