title: Basic I/O performance in Haskell
body: <p>Another microbenchmark: Why is this "loop" (compiled with <code>ghc -O2 -fllvm</code>, 7.4.1, Linux 64bit 3.2 kernel, redirected to <code>/dev/null</code>)</p>
  
  <pre><code>mapM_ print [1..100000000]
  </code></pre>
  
  <p>about 5x slower than a simple for-cycle in plain <code>C</code> with <code>write(2)</code> non-buffered syscall? I am trying to gather Haskell gotchas.</p>
  
  <p><em>Even this slow C solution is much faster than Haskell</em></p>
  
  <pre><code>int i;
  char buf[16];
  for (i=0; i&lt;=100000000; i++) {
      sprintf(buf, "%d\n", i);
      write(1, buf, strlen(buf));
  }
  </code></pre>