Skip to content

Instantly share code, notes, and snippets.

@joeriks
Created June 16, 2013 13:06
Show Gist options
  • Select an option

  • Save joeriks/5791981 to your computer and use it in GitHub Desktop.

Select an option

Save joeriks/5791981 to your computer and use it in GitHub Desktop.
var sw = new System.Diagnostics.Stopwatch();
var x = new []{"foo","bar","baz"};
sw.Start();
foreach(var iterations in Enumerable.Range(1,10000000))
{
var result = x.Aggregate ((a,s)=>a+ ", " + s);
}
sw.ElapsedMilliseconds.Dump();
var sw = new System.Diagnostics.Stopwatch();
var x = new []{"foo","bar","baz"};
sw.Start();
foreach(var iterations in Enumerable.Range(1,10000000))
{
var result = string.Join(", ",x);
}
sw.ElapsedMilliseconds.Dump();
@bomortensen
Copy link

It's one of these situations where readability should be preferred over the unnoticeable performance difference ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment