Tuesday, March 2, 2010

Reflection performance

The following is the reference on reflection performance:

http://msdn.microsoft.com/en-us/magazine/cc163759.aspx
http://www.drdobbs.com/windows/184416570

Basically, to speed up the reflection, you should do this:
1. Cache the object instance that you have created and reuse it later.
2. Using Interface or delegate to invoke the method instead of MethodInfo.Invoke.
3. Create the assembly dynamically using Reflection.Emit.