Skip to content

Instantly share code, notes, and snippets.

@xtqqczze
Created April 9, 2021 12:08
Show Gist options
  • Save xtqqczze/22cfeb3eb34e4ca21f4af87adf4956a5 to your computer and use it in GitHub Desktop.
Save xtqqczze/22cfeb3eb34e4ca21f4af87adf4956a5 to your computer and use it in GitHub Desktop.
ConvertAllBenchmark
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Collections.Generic;
using System.Linq;
[MemoryDiagnoser]
[DisassemblyDiagnoser]
public class Program
{
private List<int> list = Enumerable.Repeat(10, 10).ToList();
static void Main()
{
BenchmarkRunner.Run<Program>();
}
[Benchmark]
public List<string> M()
{
return list.Select(t => t.ToString()).ToList();
}
[Benchmark]
public List<string> N()
{
return list.ConvertAll(t => t.ToString());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment