title: Why is Console.WriteLine(...) too slow? Any alternatives?
body: <p>It seems <code>Console.WriteLine(...)</code> is really slow in C#.</p>
  
  <p>Here's the code I tested.</p>
  
  <pre><code>var iterations = 5000;
  var watch = new Stopwatch();
  watch.Start();
  for (int i = 0; i &lt; iterations; i++) 
      Console.WriteLine("adsdsaddhfuihdsuifhdsufudshfoadfdshoadsuoadsuioadsihfuidh");
  watch.Stop();
  double msPerOp = 1.0 * watch.ElapsedMilliseconds / iterations;
  Console.WriteLine("{0} ms/op", msPerOp);
  </code></pre>
  
  <p>In my laptop, it prints <code>5.731 ms/op</code>.</p>
  
  <p>Why is it so slow?</p>
  
  <p>As far as I know, printing to console in other languages is not this slow.
  For example, in Go, <code>fmt.Println(...)</code> with same string only takes <code>416275 ns/op (= 0.416275 ms/op)</code> in my laptop. </p>
  
  <p>(tested with <code>go test -bench .</code>)</p>
  
  <p>Why is <code>Console.WriteLine(...)</code> so slow in c#? Is there any alternative I can use which has a performance similar with Go's <code>fmt.Println(...)</code>?</p>
  
  <p>EDIT)
  The reason I need fast <code>Console.WriteLine(...)</code> is following.</p>
  
  <p>My application continuously receives a lots of real time data (20~80 data/sec) by windows message loop, and I want to simply print the data every time I receive with <code>Console.WriteLine</code>. I should print it fast because if not, real time data gets delayed.</p>
  
  <p>However, it seems <code>Console.WriteLine(...)</code> takes 5~10ms (for long string).. and this is too slow for real time data processing.</p>