Skip to content

Conversation

@stephentoub
Copy link
Member

Allows nint and nuint to participate in the same optimizations in string building / formatting as do the other primitives.

cc: @tannergooding

using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Running;

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

    private nint _value = 123456789;

    [Benchmark]
    public string Format() => $"Value: {_value}";
}
Method Job Toolchain Mean Ratio Allocated
Format Job-RUVFJN \master\corerun.exe 81.18 ns 1.00 120 B
Format Job-IDOMKL \pr\corerun.exe 68.24 ns 0.84 80 B

(Separately, we might want to expose these TryFormat methods publicly.)

Allows nint and nuint to participate in the same optimizations in string building / formatting as do the other primitives.
@stephentoub stephentoub added this to the 6.0.0 milestone Nov 10, 2020
@tannergooding
Copy link
Member

This LGTM. However, do we need to take this to API review just for consistencies sake (even if just a quick over e-mail confirmation)?

@stephentoub
Copy link
Member Author

stephentoub commented Nov 10, 2020

However, do we need to take this to API review just for consistencies sake (even if just a quick over e-mail confirmation)?

These are internal.

But we can open an issue about exposing them.

@tannergooding
Copy link
Member

Ah right, I forgot ISpanFormattable was internal. 👍

@jkotas jkotas merged commit 0efefa8 into dotnet:master Nov 11, 2020
@stephentoub stephentoub deleted the intptrformattable branch November 11, 2020 03:41
@ghost ghost locked as resolved and limited conversation to collaborators Dec 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants