我用展鹏做一些绩效评估。使用 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.
https://vagifabilov.word$p$pss.com/2010/04/02/dont-use-activator-createinstance-or-constructorinfo-invoke-use-compiled-lambda-ex$p$pssions/