-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Processing dotnet/runtime#116150 (comment) command:
Command
-arm -amd -intel
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Runtime.CompilerServices;
BenchmarkSwitcher.FromAssembly(typeof(Bench).Assembly).Run(args);
[DisassemblyDiagnoser]
[MemoryDiagnoser(false)]
public class Bench
{
[Benchmark]
[ArgumentsSource(nameof(GetLists))]
public int SumList(List<string> list)
{
int sum = 0;
foreach (var item in list)
{
sum += Process(item);
}
return sum;
}
[Benchmark]
[ArgumentsSource(nameof(GetLists))]
public int SumEnumerable(IEnumerable<string> list)
{
int sum = 0;
foreach (var item in list)
{
sum += Process(item);
}
return sum;
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static int Process(string item) => item.Length;
public static IEnumerable<List<string>> GetLists() =>
from count in new int[] { 1, 10, 1_000 }
select Enumerable.Range(0, count).Select(i => i.ToString()).ToList();
}
(EgorBot will reply in this issue)
Metadata
Metadata
Assignees
Labels
No labels