views:

79

answers:

3

I rewrote a number-crunching two pages of code from C# to unmanaged C++ in my project, which with full optimizations gave a 3x speedup. I want to keep optimizing that code, but now my profiler of choice, dotTrace, can't do it, because it only looks at managed code.

How do I profile the P/Invoked C++ module when it's running in the C# app?


And a tangential question: Calling the following function via P/Invoke doesn't produce any unneeded overhead (such as copying the arrays), right? Just making sure. (Note that Foo both reads from bar and writes to it)

// From the C# side:
[DllImport("foo.dll")]
static extern void Foo(float[,] bar);

// From the C++ side:
extern "C" __declspec(dllexport)
void Foo(float* bar);

compiler: msvc on Vista

A: 

AQtime can profile both native and managed code. It's very powerful tool.

elder_george
+1  A: 

How about making a standalone test harness for the C++ code and profiling it alone with any number of tools like VTune, callgrind, Quantify, oprofile...?

John Zwinck
A: 

The Visual Studio profiler works with mixed mode apps. It's (unfortunately) hard to get access to in VS 2008, but it is included in the VS 2010 Ultimate beta that you can download for free here

Nathan Howell