6 ms·
This is not a real disabling of dbg. dbg.h should support a function that disables writing out to the screen, but still returning the expression during run-tim
by xiphias2 7y ago
This is not a real disabling of dbg.
dbg.h should support a function that disables writing out to the screen, but still returning the expression during run-time.
You could try it out with something like this:
disable_dbg_output();
int a = 0;
for(int i=0; i<1000000000; i++) {
a += dbg(i);
}
- asah 7y agoyes, correct - my code is just the performance test, which IMHO is the first step and surprisingly tricky due to effects from the loop around it. The code for dynamic enable/disable is trivial but the design is a bit subjective. For example, another API might be set_dbg_output(bool) and then maybe get_dbg_output() to inspect the current state.
- pnako 7y agoAn alternative route might be to find a way to integrate this code with a logging library like spdlog. This way you'd get the cool short notation of dbg(...) and the ability to have more control about the sinks (including indeed dynamic disabling/enabling).