During recent work on personal projects, I discovered that my OutputStream library manipulators weren’t always behaving as expected.
Investigation determined that I needed to change the class usage slightly to enforce user selection of one of the two template classes that derive from their shared BasicStream ancestor.
In OutputStreams 2.0, declaring streams and channels changes a little and much of the potentially confusing aliasing nomenclature has been removed. It requires minimal effort to tweak client code to the new declaration syntax (it took me less than three minutes to get the OutputStreams googletest suite updated to v2.0)
I also took the time to tweak the class designs: deferring some OutputStream functionality to the StreamBuffer class, for example.
I’m seeing encouraging initial performance statistics – the design certainly does appear to minimise output bottlenecks in a multi-threaded environment.
Initial stats on OutputStreams 2.0 running on an Intel Core i7 processor on Windows and a Virtual Ubuntu Linux distribution on the same PC follow:
50 consecutive tests of three threads forcing a moderately complex output statement 5000 times (total output statements – not per thread) through the following output methods to the active console:
Windows:
printf – Best: 157ms, Worst: 266ms, Average: 188ms
std::cout – Best: 5076ms, Worst: 8200ms, Average: 6324ms
OutputChannel – Best: 14ms, Worst: 20ms, Average: 15ms
Linux:
printf – Best: 36ms, Worst: 151ms, Average: 93ms
std::cout – Best: 56ms, Worst: 159ms, Average: 114ms
OutputChannel – Best: 2ms, Worst: 33ms, Average: 7ms
As is usual when developing somewhat complex code, I encountered other problems not of my own making along the way: memory leaks from Microsoft STL objects; an inability to get GCC to build a multi-threaded Linux executable that can stand alone without run-time libraries – I find this one somewhat bizarre given the addition of std::thread to the standard in 2011).
I’m currently performing final tests before I update all the docs and publish, so expect a release in a couple of weeks.