Skip to content

Conversation

@stephentoub
Copy link
Member

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System;
using System.Globalization;
using System.Linq;
using System.Reflection;

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

    private AssemblyName[] _names = AppDomain.CurrentDomain.GetAssemblies().Select(a => new AssemblyName(a.FullName)).ToArray();

    [Benchmark]
    public int Names()
    {
        int sum = 0;
        foreach (AssemblyName name in _names)
        {
            sum += name.FullName.Length;
        }
        return sum;
    }
}
Method Toolchain Mean Error StdDev Ratio Allocated
Names \main\corerun.exe 3.654 us 0.0285 us 0.0238 us 1.00 10 KB
Names \pr\corerun.exe 2.205 us 0.0202 us 0.0189 us 0.60 2 KB

@ghost
Copy link

ghost commented Mar 17, 2022

I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label.

@ghost ghost assigned stephentoub Mar 17, 2022
@stephentoub stephentoub added this to the 7.0.0 milestone Mar 17, 2022
@stephentoub stephentoub added the tenet-performance Performance related issue label Mar 17, 2022
Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@stephentoub stephentoub merged commit ac84ea6 into dotnet:main Mar 17, 2022
@stephentoub stephentoub deleted the assemblynamestring branch March 17, 2022 11:31
radekdoulik pushed a commit to radekdoulik/runtime that referenced this pull request Mar 30, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Apr 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

tenet-performance Performance related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants