Created
April 9, 2021 12:08
-
-
Save xtqqczze/22cfeb3eb34e4ca21f4af87adf4956a5 to your computer and use it in GitHub Desktop.
ConvertAllBenchmark
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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