The code for this post can be found at: https://github.com/Atrix256/STLCost
Folks often will say STL containers are slow in debug, other folks say they aren’t.
Frankly, both are true. “Slow” as a negative statement depends both on what you are doing with them, as well as your need for debug performance.
In game development, you must absolutely be able to run a game in debug mode, and you are usually manipulating a lot of data. This is true both of games at runtime, as well as tool time operations.
This post looks at a pretty common tool time operation: making box filtered mip maps of a 512×512 RGBA F32 image.
This is in MSVC 2017, debug x64, using default project settings.
On my machine, it’s about 25 milliseconds to do this operation with a plain c style array. it’s about 240 milliseconds to do it with a std::array. It’s about 1900 milliseconds to do it with a std::vector.
This example is in line with my own experience that these basic STL containers are really slow in debug, and will bring a debug build to it’s knees. An unusable debug build is hell on a team and will significantly bring down productivity. It can be a project killer, especially as it makes it more difficult for folks to debug problems and validate that things are working correctly.
Maybe perf is better on other compilers though?
Have anything to add, correct, etc? Speak up! 🙂