Skip to content

Instantly share code, notes, and snippets.

@ChrisKulesza
Forked from joeriks/aggregate.cs
Created February 19, 2022 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisKulesza/c1b08ab2648780acd36a4b6bd156e85c to your computer and use it in GitHub Desktop.
Save ChrisKulesza/c1b08ab2648780acd36a4b6bd156e85c 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();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment