title: Overhead - Calling C++ function from C#
body: <p>I am calling two C++ functions from C#. While doing that in a iteration for around 1 million call i am seeing a overhead of about 30%. </p>
  
  <p>C++ function :</p>
  
  <pre><code>EXTERN_C void STDAPICALLTYPE FunctionA(UINT_PTR mathId)
  {
      ...
      ...
  }
  </code></pre>
  
  <p>In my C# assembly dll as :</p>
  
  <pre><code>[DllImport("CPlusPlus.dll")]
      public static extern void FunctionA([In] IntPtr mathID);
  </code></pre>
  
  <p>Called from function as below:</p>
  
  <pre><code> public static void HelpingFunction([In]UInt64 mathID)
      {
          FunctionA((IntPtr)mathID);
      }
  </code></pre>
  
  <p>This way of implementation is creating more overhead when the "HelpingFunction" is called more than a million times. </p>
  
  <p>Can someone give me other ideas so that the overhead can be reduced? What are the other ways to call a C++ function from a C# assembly?</p>