views:

44

answers:

1

I am trying to determine if the COM interop is becoming a bottle neck in my software. This article on MSDN helps http://msdn.microsoft.com/en-us/library/ms998579.aspx#scalenetchapt15%5Ftopic11. But I really do not have have a point of reference for a "normal" or "high" value for # of marshalling to determine if it is impacting performance. Can anyone give me a threshold for this performance counter like MSDN gives for other performance counters in the article. I know this is a hardware and application specific question but any help would be appreciated.

+1  A: 

I don't think it is possible to indicate a specific threshold for marshalling. It is application dependent. What you should do is measure how long each call takes on average. Write a test application that simply makes a bunch of calls to unmanaged code and time it. Then using the "Chattiness" counter on your application, you should be able to estimate the total cost of the switches between managed and unmanaged code.

I had to do this exact thing a couple of years ago. I was using an unmanaged DLL to read values from a chunk of data. I measured the calls and found it to be relatively expensive due to the high number of calls, so I made a single call to retrieve the chunk of data and then extracted the values from that data in managed code. It was more work to code but provided a fairly significant speed increase.

Mark Wilkins