Skip to content

Conversation

@stephentoub
Copy link
Member

Just stop doing unnecessary work.

Method Toolchain Mean Ratio Allocated
Get \main\corerun.exe 826.7 ns 1.00 664 B
Get \pr\corerun.exe 488.1 ns 0.59 104 B
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System;
using System.Reflection;

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

    private PropertyInfo _prop = typeof(B).GetProperty("MyProp");

    [Benchmark]
    public Attribute[] Get() => Attribute.GetCustomAttributes(_prop, inherit: true);
}

class A { }

class B : A
{
    [My]
    public int MyProp { get; set; }
}

class MyAttribute : Attribute { }

@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 89b39c5 into dotnet:main Jun 21, 2021
@stephentoub
Copy link
Member Author

Failure is #54125

Thanks. I kept trying to figure out how my changes were causing these :)

@stephentoub stephentoub deleted the inheritattributes 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.

Labels

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

2 participants