如何昂贵是.NET反射?反射、昂贵、NET

由网友(善解人衣)分享简介:我经常听到多么糟糕的思考是使用。虽然我一般避免反光,很少发现情况就不可能解决我的问题,没有它,我不知道...... I constantly hear how bad reflection is to use. While I generally avoid reflection and rarely find si...

我经常听到多么糟糕的思考是使用。虽然我一般避免反光,很少发现情况就不可能解决我的问题,没有它,我不知道......

I constantly hear how bad reflection is to use. While I generally avoid reflection and rarely find situations where it is impossible to solve my problem without it, I was wondering...

对于那些谁在应用中使用的反射,让你测量的性能命中和,是不是真的那么差?

For those who have used reflection in applications, have you measured performance hits and, is it really so bad?

推荐答案

有。但是,这取决于你正在努力做的事情。

It is. But that depends on what you're trying to do.

我用反射动态加载程序集(插件),其性能惩罚是没有问题的,因为操作一些应用程序的启动过程中我做的。

I use reflection to dynamically load assemblies (plugins) and its performance "penalty" is not a problem, since the operation is something I do during startup of the application.

不过,如果你在里面反映了一系列的嵌套循环与每个反射的电话,我说你应该重新审视你的code:)

However, if you're reflecting inside a series of nested loops with reflection calls on each, I'd say you should revisit your code :)

有关一对夫妇的时候行动,反思是完全可以接受的,你不会注意到任何延迟或问题的。这是一个非常强大的机制,它甚至使用.NET,所以我不明白为什么你不应该给它一个尝试。

For "a couple of time" operations, reflection is perfectly acceptable and you won't notice any delay or problem with it. It's a very powerful mechanism and it is even used by .NET, so I don't see why you shouldn't give it a try.

阅读全文

相关推荐

最新文章