Improving Reflection Performance
Here are some ways to reduce some of the cost of reflection and of the MemberInfo cache.
- Avoid using Type.InvokeMember to call late-bound methods
- Avoid case-insensitive member lookups
- Use BindingFlags.ExactMatch whenever possible
- Call the non-plural GetXX method if you know the name of the instance you care about (.NET Framework 2.0 only)
- Cache only the handle to a member (.NET Framework 2.0 only)
Adopted from Joel Pobar's excellent article Reflection: Dodge Common Performance Pitfalls to Craft Speedy Applications.
0 Comments:
Post a Comment
<< Home