Q:

Conditional optimization in Visual Studio

I have a code like this:
void f()
{
  //Some function I want to debug
  g();
  //More code
}
void g()
{
  //A very slow function I want to have optimized for performance
  //No debugging this code
}

Where f is whatever function in my code I want to debug and g is a function computationally intensive. 
When I compile the code with Release configuration, both pieces of code get optimized and it all runs in a reasonable time, but when I compile with Debug configuration, then g takes way too long to execute as the compiler don't optimize the code to keep it debugger-friendly. 
I don't need to deal with g from a debugging point of view and can not extract it into a pre-compiled module (it's under active development and need to keep it up to date). They are defined in different files.
Is there a way to tell Visual Studio to compile g for speed, while keeping f compiled using Debug configuration?

A:

You can either move f into another compilation unit, e.g. another file or #pragma optimize. The latter is probably the better choice because it's harder to forget you set that up than changing the compilation settings on a particular file, which you would have to remember to go back and reset. 
Or you could just profile in debug mode and see what's happening. As VS Premium and above include these tools that shouldn't be too hard, or you can use a third party tool. Profiling usually gives a really good idea of what's the true cause of any slowdown.

