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

Replace StringBuilder with ValueStringBuilder in AssemblyName.FullName #66750

Merged
merged 1 commit into from
Mar 17, 2022

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

@dotnet-issue-labeler
Copy link

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.

None yet

4 participants