I call two C ++ functions from C #. Performing this at an iteration of about 1 million calls, I see an overhead of about 30%.
C ++ function:
EXTERN_C void STDAPICALLTYPE FunctionA(UINT_PTR mathId)
{
...
...
}
In my c # dll assembly:
[DllImport("CPlusPlus.dll")]
public static extern void FunctionA([In] IntPtr mathID);
Called from a function, as shown below:
public static void HelpingFunction([In]UInt64 mathID)
{
FunctionA((IntPtr)mathID);
}
This implementation method creates additional overhead when the HelpingFunction is called more than a million times.
Can someone give me other ideas to reduce overhead? What are other ways to call a C ++ function from a C # assembly?
source
share