-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Processing dotnet/runtime#109209 (comment) command:
Command
-intel -arm64 -profiler --envvars DOTNET_JitDisasm:Foreach Count
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Runtime.CompilerServices;
BenchmarkSwitcher.FromAssembly(typeof(Bench).Assembly).Run(args);
public class Bench
{
string[] s_ro_str_array = new string[512];
[Benchmark]
public int Foreach()
{
IEnumerable<string> e = s_ro_str_array;
int sum = 0;
foreach (string s in e) sum += s == null ? 0 : s.Length;
return sum;
}
[Benchmark]
public int Count() => CountInner(s_ro_str_array);
[MethodImpl(MethodImplOptions.NoInlining)]
int CountInner(ICollection<string> c) => c.Count;
}
(EgorBot will reply in this issue)
Metadata
Metadata
Assignees
Labels
No labels