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.