Hacker News new | ask | show | jobs
by Const-me 618 days ago
OP’s benchmark doesn’t use the return value from the function being benchmarked. When C++ compilers are asked to optimize such code, they often optimize away the whole function.

Pretty sure your 17.7 nanoseconds result had the whole function optimized away. Workarounds are tricky and compiler-specific.