Skip to content

Conversation

@stephentoub
Copy link
Member

It's common to ask for attribute information on members that don't have attributes (which you only discover by asking).

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Collections.Generic;
using System.Reflection;

[MemoryDiagnoser]
public class Program
{
    static void Main(string[] args) => BenchmarkSwitcher.FromAssemblies(new[] { typeof(Program).Assembly }).Run(args);

    private MethodInfo _mi = typeof(Program).GetMethod("MyMethod");

    public void MyMethod() { }

    [Benchmark]
    public IList<CustomAttributeData> Get() => _mi.GetCustomAttributesData();
}
Method Toolchain Mean Ratio Allocated
Get \main\corerun.exe 77.13 ns 1.00 48 B
Get \pr\corerun.exe 72.08 ns 0.93 -

@stephentoub stephentoub added this to the 6.0.0 milestone Jun 18, 2021
@jkotas
Copy link
Member

jkotas commented Jun 21, 2021

Failure is #54125

@jkotas jkotas merged commit 1ccd65f into dotnet:main Jun 21, 2021
@stephentoub stephentoub deleted the emptycustomattrs branch June 21, 2021 18:02
@ghost ghost locked as resolved and limited conversation to collaborators Jul 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

2 participants