Search code examples
c++visual-studio-debugging

Optimization in debug mode


I have code which runs rather slow, but I know it needs no debugging. I have a third-party hardware attached to my system which works only in debug mode (yeah really, pain in the a%$).

So I wanted to turn the optimization on for my function, but it uses the precisely same time between debug normal mode and optimization turned on.

#pragma optimize("ts", on)
void DataAnalyze::PrepareData(std::vector<short>& data, std::vector<short>& laserData, std::vector<std::vector<double>>& normalizedData) {
...
}
#pragma optimize("ts", off)

Does that only work in release mode to turn optimization off, or am I missing something?


Solution

  • After reading the comments realizing this was caused by STL, I switched to using short* instead to access the vector, and that sped up my code by a factor of 3.