Reputation: 122
I now understand that WinRT is an API on top of several implementations (Win32 for example) but provided it in an"Oriented Object" way thanks to COM, and the new ECMA 335/CLI metadata. (see How does Windows 8 Runtime (WinRT / Windows Store apps / Windows 10 Universal App) compare to Silverlight and WPF?)
As a .Net developper, I always learned to avoid as much as possible P/Invoke, COM or every "external/interop" calls because of the bad performance. (if we can use a C++/CLI wrapper for native library calls it's always better)
Upvotes: 2
Views: 718
Reputation: 52699
Your problem with performance with COM (or WinRT, which is COM basically) will come down to being exceptionally "chatty" (ie making a lot of calls in a very short time) or with data marshalling.
Any method call that takes a small amount of time will hurt performance if you call it all the time. So I assume that a WinRT call is not as fast as a call from one method to another inside the same .NET assembly (I assume the JIT will optimise it away or optimise it to be insignificant). If the same level of optimisation cannot be made, then you'll notice the method calls - if you overdo it. For example, people used to say virtual method calls in C++ hurt performance, simply because they required a vtable indirection that couldn't be optimised to nothing like normal function calls.
The biggest performance hit though is data, making a call to an external system usually requires that your data gets translated into a format the other system can understand - that is a bigger perf hit than you realise. Even if you do not have to marshal it, you often have to copy the data - so instead of passing 4 bytes of a reference pointer, you have to copy the entire data, or pin it so it can still be accessed from the other system outside of your calling environment. This can hurt perf in a smaller way, but still is not as fast as the direct call.
I'd say in both cases, calling WinRT methods is not going to hurt you so much, there is a layer between .NET and WinRT (similar to the old auto-generated COM wrappers) but is apparently much lighter.
Upvotes: 3
Reputation: 25601
There's no magic in a WinRT object that makes it execute faster than an equivalent traditional COM object. They are both COM. What will be faster though, is the time to market - WinRT is a lot easier to deal with as a developer.
You answered to that already by yourself.
Upvotes: 1