Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Special-case no attributes in GetCustomAttributeData #54405

Merged
merged 1 commit into from
Jun 21, 2021

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 -

@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