mercredi 22 octobre 2008

What's Slow and What's Not with .NET 2.0 Reflection API?

For quick reference, keep in mind that :

Fast and Light Functions
typeof 
Object.GetType 
typeof == Object.GetType 
Type equivalence APIs (including typehandle operator overloads) 
get_Module 
get_MemberType 
Some of the IsXX predicate APIs 
New token/handle resolution APIs in the .NET Framework 2.0 


Costly Functions
GetXX APIs (MethodInfo, PropertyInfo, FieldInfo, and so on) 
GetCustomAttributes 
Type.InvokeMember 
Invoke APIs (MethodInfo.Invoke, FieldInfo.GetValue, and so on) 
get_Name (Name property) 
Activator.CreateInstance

to have much more details on :
- When to use reflection,
- Early-Bound, Hybrid-bound and Late-Bound Invocation,
-  the MemberInfo cache, 
...

Aucun commentaire: