Would be nice to offer runtime enable/disable. Out of curiosity, I wrote a little benchmark and submitted as a PR: <a href="https://github.com/sharkdp/dbg-macro/pull/57" rel="nofollow">https://github.com/sharkdp/dbg-macro/pull/57</a><p>The key idea is that modern CPUs dynamically branch-predict-away if-statements that are rarely/never invoked, such as a dynamically disabled dbg() call.<p>With the performance difference magnified 10x by loop unrolling, this is what I'm seeing on my Mac laptop:<p>830000000 iterations in 3 secs = 2.76667e+08 iters/sec (compiled-out).
840000000 iterations in 3 secs = 2.8e+08 iters/sec (dynamically disabled).<p>And this is the worst case, where the whole program does nothing but call dbg() - real world programs contain lots of other real work, drowning the minute difference in performance, i.e. in a real program I doubt you'd see even 0.1% total performance difference, littering it with dynamic dbg() statements.<p>p.s. my C/C++ is pretty rusty - feedback welcome, but pls be kind.