https://github.com/ksemenenko/createinstance
Comparison of methods for creating a new instance in C#
https://github.com/ksemenenko/createinstance
activator comparison createinstance net-framework
Last synced: 11 months ago
JSON representation
Comparison of methods for creating a new instance in C#
- Host: GitHub
- URL: https://github.com/ksemenenko/createinstance
- Owner: KSemenenko
- Created: 2016-01-27T11:47:31.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2017-02-23T13:52:24.000Z (almost 9 years ago)
- Last Synced: 2025-01-09T07:14:41.660Z (about 1 year ago)
- Topics: activator, comparison, createinstance, net-framework
- Language: C#
- Homepage:
- Size: 25.4 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## CreateInstance
Comparison of methods for creating a new instance in .net
[blogs.msdn.microsoft.com](https://blogs.msdn.microsoft.com/seteplia/2017/02/01/dissecting-the-new-constraint-in-c-a-perfect-example-of-a-leaky-abstraction/)
### Results:
``` ini
BenchmarkDotNet=v0.10.1, OS=Microsoft Windows NT 6.2.9200.0
Processor=AMD FX(tm)-8300 Eight-Core Processor , ProcessorCount=8
Frequency=3237665 Hz, Resolution=308.8646 ns, Timer=TSC
[Host] : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1586.0 [AttachedDebugger]
DefaultJob : Clr 4.0.30319.42000, 64bit RyuJIT-v4.6.1586.0
Method | Mean | StdDev | Scaled | Scaled-StdDev | Gen 0 |
--------------------------------------- |----------- |---------- |------- |-------------- |------- |
Contrustor | 7.3578 ns | 0.4366 ns | 1.00 | 0.00 | 0.0252 |
new T() | 98.5826 ns | 4.9480 ns | 13.44 | 1.03 | 0.0223 |
Activator.CreateInstance | 83.5369 ns | 3.6547 ns | 11.39 | 0.82 | 0.0234 |
Activator.CreateInstance | 97.1237 ns | 5.3454 ns | 13.24 | 1.05 | 0.0190 |
FastObjectFactory | 10.9606 ns | 0.6253 ns | 1.49 | 0.12 | 0.0252 |
ExpressionsActivator | 16.3574 ns | 0.7848 ns | 2.23 | 0.17 | 0.0246 |
DynamicModuleLambdaCompiler | 9.2815 ns | 0.5401 ns | 1.27 | 0.10 | 0.0247 |
FastActivator.Create | 9.5878 ns | 0.8076 ns | 1.31 | 0.13 | 0.0252 |
FastActivator.CreateInstance | 25.7931 ns | 1.3172 ns | 3.52 | 0.27 | 0.0240 |
ExtensionsNew.NewFactory | 17.0394 ns | 1.1198 ns | 2.32 | 0.20 | 0.0252 |
ExtensionsNew.NewFactory | 19.6788 ns | 1.4862 ns | 2.68 | 0.25 | 0.0247 |
ExtensionsNew.NewFactory with params | 92.4184 ns | 3.1951 ns | 12.60 | 0.85 | 0.1244 |
ExtensionsNew.NewFactory with params | 97.7812 ns | 3.9581 ns | 13.33 | 0.94 | 0.1209 |
```