Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Here's the final result:</h2> <p>I changed the format string in a benchmark trial to something that should favor my code a little more:</p> <blockquote> <p>The quick brown {0} jumped over the lazy {1}.</p> </blockquote> <p>As I expected, this fares much better compared to the original; 2 million iterations in 5.3 seconds for this code vs 6.1 seconds for <code>String.Format</code>. This is an undeniable improvement. You might even be tempted to start using this as a no-brainer replacement for many <code>String.Format</code> situations. After all, you'll do no worse and you might even get a small performance boost: as much 14%, and that's nothing to sneeze at.</p> <p>Except that it is. Keep in mind, we're still talking less than half a second difference for 2 <em>million</em> attempts, under a situation specifically designed to favor this code. Not even busy ASP.Net pages are likely to create that much load, unless you're lucky enough to work on a Top100 web site. </p> <p>Most of all, this omits one important alternative: you can just create a new <code>StringBuilder</code> each time and manually handle your own formatting using raw <code>Append()</code> calls. With that technique my benchmark finished in <em>only 3.9 seconds.</em> That's a much greater improvement. </p> <p>So in the end, if you're in a situation where the performance matters there is a better alternative available. And if it doesn't matter, you probably want to stick with the clarity of using the simple built-in method.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload