mardi 9 juin 2015

GetTypeInfo Performance in Windows Store Apps

When porting from the .Net Framework 4.5 to a Portable Class Library profile or Windows Store apps, a big change for Reflection-heavy libraries and applications is transitioning over to the Evolved Type System, i.e. moving from Type to TypeInfo.

It might be tempting to do it the easy way and transform a lot of code from this:

someType.AccessReflectionAPI();

...to something like this:

someType.GetTypeInfo().AccessReflectionAPI();

This makes a lot of GetTypeInfo calls, which leaves me worrying. Since in the .Net Framework 4.5 TypeInfo derives from Type, the GetTypeInfo implementation is trivial (and might even be JIT-inlined?), but what about the implementation for Windows Store Apps and .Net Core?

How big of an impact is calling GetTypeInfo on those platforms? Will each call create a new object? Will each call mean a dictionary lookup? What's the overhead here?





Aucun commentaire:

Enregistrer un commentaire