Hello all,

this is probably a wrong place to write this post, but I hope to receive your thoughts anyway. Writing to moderated c++ group might open my email address to spammers, so I decided to write my post here.

One of my collegues told me once that C++ streams are slower then Java. We did some trials (on a Win32 platform with Visual C++ 7.1) and he was able to prove this. Today when I read the standard on output steams I came accross the point, that most all stream functions must construct the nested sentry type. I suddenly remembered the article written by Nathan Myers on locales available at:
http://www.cantrip.org/locale.html

There he states, that in sentry a locking might be made in a multi-threaded environment. I looked in the implemenation of my STL distribution (which by default bundled with VC++ 7.1) and here we go. sentry locks in ctor and unlocks in dtor. So writing a character by character or integer by integer will produce the whole bunch of lock/unlock sequences, since standard states (in §27.6.2.5.4)  that every call to operator << has to create sentry object instance and that explains to me why the std streams (at least on Windows are much slower as on Java).

Would be great to hear your thoughts...


Regards,
Ovanes