Reflection Performance - Is It That Bad?

posted on 08/10/07 at 01:36:46 am by Joel Ross

Part of our framework that we use at NuSoft utilizes a ton of reflection. I get questions about the performance of that all the time, and my basic answer is that most likely it's fast enough, as we don't build a ton of applications that do a ton of real time processing where every millisecond is important - most are web sites where the time to process a page is a fraction of the time it takes to round-trip the data back to the browser.

Having said that, I've never had any real data to back up my assertions - I just never spent the time to measure it. But someone has, and found that using reflection to construct an object, while slower than the "normal" process is slow, it's still only about .08% of the processing time for a page. His conclusion: Yes, it's slow, but it doesn't matter.

On the other hand, I have seen reflection cause major slow downs when doing?a lot of it - for example,?populating large lists of objects. Like all things, it can be good for you in small doses, but you can definitely OD if you're not careful.

Categories: Development