On my home system (2.4GHz P4 running Gentoo & gcc-3.3) these are the numbers I got (this is the average time per iteration):


CVS logstream
Logging when disabled: 1600-1800ns
Logging when enabled: 13000-15000ns

My LoggingStream
Logging when disabled: 40-50ns
Logging when enabled: 15000-18000ns



The benchmark, like all benchmarks, is synthetic. This one assumes that a log stream is allocated for each logging request which I would assume is very atypical. I'd expect that most of the cost is in the construction of std::basic_stringbuf, but would love to see a profile on it. The initialization cost of std::basic_ostream itself appears to be vanishingly small (copy a pointer). A streambuf that did not allocate 512 characters on construction, but only when the first characters were logged would likely cut things way way down.



Reply via email to