title: Performance of sprintf vs String.Format
body: <p>I was comparing the performance of sprintf usages and am a little troubled by what I saw.  I tested the following 4 methods, passing an instance of ClassWithToString in to each (except for PrintInt, which received the actual integer value).</p>
  
  <pre><code>type ClassWithToString() =
      member this.X = 42
      override this.ToString() = this.X.ToString()
  
  let Print item : string =
      sprintf "%A" item
  
  let PrintInt item: string =
      sprintf "%i" item
  
  let PrintObj item: string =
      sprintf "%O" item
  
  let Format item : string =
      System.String.Format("{0}", item)
  </code></pre>
  
  <p>The results for 50,000 iterations:</p>
  
  <pre><code>Print (%A):     3143ms
  PrintInt (%i):   355ms
  PrintObj (%O):   384ms
  Format:            8ms
  </code></pre>
  
  <p>For "Print," I understand %A is using reflection so the sluggishness there is not shocking, though for 50k iterations I was surprised at the total time.  Following that, "PrintInt" and "PrintObj" do not use reflection and thus are an order of magnitude faster, which also makes sense.</p>
  
  <p>The part that confounds me is that in light of the results of <code>String.Format()</code> sprintf in general appears to be dreadfully slow (and has been witnessed in profiles of live applications).  Why is sprintf magnitudes slower than String.Format()?  Is there a better alternative in the F# space that I've missed? </p>