Surprising benchmark results
Have been using Google Benchmark to identify what core C++ functions cost in terms of runtime. std::complex being the subject of todays tests. Building with CMake, with the debug build, constructing an std::complex using std::polar takes some 135ns on *this box. Building the same trivial test using CMake’s release mode, this construction time drops to 0.56ns - A pretty huge difference. Extracting the real and imaginary components sees a difference of 193ns for the debug build, and 17ns for release.
In comparison, an std::sin() operation is taking 16ns in debug, and 14ns in release. Not a huge difference. I’ve not looked under the hood to see what exactly goes on inside std::complex, nor do I really want to. Just happy to know that there is not a lot of overhead using std::complex for release (production) code. Certainly makes writing code that uses vector math a lot easier.