title: How to get IOStream to perform better?
body: <p>Most C++ users that learned C prefer to use the <code>printf</code> / <code>scanf</code> family of functions even when they're coding in C++.</p>
  
  <p>Although I admit that I find the interface way better (especially POSIX-like format and localization), it seems that an overwhelming concern is performance.</p>
  
  <p>Taking at look at this question:</p>
  
  <blockquote>
    <p><a href="https://stackoverflow.com/questions/5164538/how-can-i-speed-up-line-by-line-reading-of-an-ascii-file-c/">How can I speed up line by line reading of a file</a></p>
  </blockquote>
  
  <p>It seems that the best answer is to use <code>fscanf</code> and that the C++ <code>ifstream</code> is consistently 2-3 times slower.</p>
  
  <p>I thought it would be great if we could compile a repository of "tips" to improve IOStreams performance, what works, what does not.</p>
  
  <p>Points to consider</p>
  
  <ul>
  <li>buffering (<code>rdbuf()-&gt;pubsetbuf(buffer, size)</code>)</li>
  <li>synchronization (<code>std::ios_base::sync_with_stdio</code>)</li>
  <li>locale handling (Could we use a trimmed-down locale, or remove it altogether ?)</li>
  </ul>
  
  <p>Of course, other approaches are welcome.</p>
  
  <p><em>Note: a "new" implementation, by Dietmar Kuhl, was mentioned, but I was unable to locate many details about it. Previous references seem to be dead links.</em></p>