-
Couldn't load subscription status.
- Fork 1
Open
Description
Processing dotnet/runtime#116771 (comment) command:
Command
-intel -arm64
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
[GenericTypeArguments(typeof(string))]
[MemoryDiagnoser]
public class A<T>
{
private IEnumerable<T> _ienumerable;
[GlobalSetup(Target = nameof(IEnumerable))]
public void SetupIEnumerable() => _ienumerable = new string[512] as IEnumerable<T>;
[Benchmark]
public T IEnumerable() => Get(_ienumerable);
[MethodImpl(MethodImplOptions.NoInlining)]
private T Get(IEnumerable<T> collection)
{
T result = default;
foreach (var item in collection)
result = item;
return result;
}
private IEnumerable<string> _ienumerable_str;
[GlobalSetup(Target = nameof(IEnumerable_str))]
public void SetupIEnumerable_str() => _ienumerable_str = new string[512];
[Benchmark]
public string IEnumerable_str() => Get_str(_ienumerable_str);
[MethodImpl(MethodImplOptions.NoInlining)]
private string Get_str(IEnumerable<string> collection)
{
string result = default;
foreach (var item in collection)
result = item;
return result;
}
}(EgorBot will reply in this issue)
Metadata
Metadata
Assignees
Labels
No labels