title: Why this method using putchar_unlocked is slower than printf and cout to print strings?
body: <p>I'm studying manners of speedup my codes for programming's competitions, using as base acceleration of input and output processing.</p>
  
  <p>I'm currently using a thread-unsafe <em>putchar_unlocked</em> function to print some tests. I believed that this function was faster than <em>cout</em> e <em>printf</em> to some data types if well implemented due to its thread-unlockable nature.</p>
  
  <p>I implemented a function to print strings this way (very simple, at my point of view):  </p>
  
  <pre class="lang-c prettyprint-override"><code>void write_str(char s[], int n){
      int i;
      for(i=0;i&lt;n;i++)
          putchar_unlocked(s[i]);
  }
  </code></pre>
  
  <p>I tested with a string of size <em>n</em> and exactly <em>n</em> characters.<br>
  But it is the slowest of three, how we can see in this graph of number of output writes versus time in seconds:
  <a href="https://i.stack.imgur.com/mQU2n.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mQU2n.png" alt="Graph"></a></p>
  
  <p>Why it's the slowest?</p>