Activator.CreateInstance性能替代 [英] Activator.CreateInstance Performance Alternative

查看:726
本文介绍了Activator.CreateInstance性能替代的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用展鹏做一些绩效评估。使用 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性能替代的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆