问题描述
我用展鹏做一些绩效评估。使用 Activator.CreateInstance
(有两个构造函数参数),走的时候一个像样的量......有没有更好的替代方案,还是采用了反射式的做法,我注意到动态地创建一个实例(未明确instantation)?
I'm using RedGate to do some performance evaluation. I notice dynamically creating an instance using Activator.CreateInstance
(with two constructor parameters) is taking a decent amount of time... is there a better alternative that still utilizes a reflective approach (not explicit instantation)?
感谢。
推荐答案
如果可以,请使用编译的lambda,它的速度要快得多。
Use a compiled lambda if you can, its MUCH faster.
<一个href="https://vagifabilov.word$p$pss.com/2010/04/02/dont-use-activator-createinstance-or-constructorinfo-invoke-use-compiled-lambda-ex$p$pssions/" rel="nofollow">https://vagifabilov.word$p$pss.com/2010/04/02/dont-use-activator-createinstance-or-constructorinfo-invoke-use-compiled-lambda-ex$p$pssions/
这篇关于Activator.CreateInstance性能替代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!