How costly is .NET reflection?

Dan Herbert picture Dan Herbert · Aug 25, 2008 · Viewed 60.8k times · Source

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?

Answer

ESRogs picture ESRogs · Aug 27, 2008

In his talk The Performance of Everyday Things, Jeff Richter shows that calling a method by reflection is about 1000 times slower than calling it normally.

Jeff's tip: if you need to call the method multiple times, use reflection once to find it, then assign it to a delegate, and then call the delegate.