-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Improve Guid parsing performance for "D", "N", "B", and "P" #55792
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
Conversation
|
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. |
|
@uweigand, I would not be at all surprised if I got the endianness wrong here. Can you take a look? |
|
Tagging subscribers to this area: @dotnet/area-system-runtime Issue Details
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System;
[MemoryDiagnoser]
public class Program
{
public static void Main(string[] args) => BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
private string _d, _b, _p, _n;
private string _invalidD;
private string _weirdD;
[GlobalSetup]
public void Setup()
{
Guid g = Guid.NewGuid();
_d = g.ToString("D");
_b = g.ToString("B");
_p = g.ToString("P");
_n = g.ToString("N");
_invalidD = _d[..^1] + "Z";
_weirdD = "+" + _d[1..];
}
[Benchmark] public bool D() => Guid.TryParseExact(_d, "D", out _);
[Benchmark] public bool N() => Guid.TryParseExact(_n, "N", out _);
[Benchmark] public bool B() => Guid.TryParseExact(_b, "B", out _);
[Benchmark] public bool P() => Guid.TryParseExact(_p, "P", out _);
[Benchmark] public bool InvalidD() => Guid.TryParseExact(_invalidD, "D", out _);
[Benchmark] public bool WeirdD() => Guid.TryParseExact(_weirdD, "D", out _);
}
|
|
@tannergooding and/or @GrabYourPitchforks, could you help with a review here? Thanks. |
GrabYourPitchforks
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a comment with potential for even further optimization, but the logic LGTM!
|
We are seeing this improvement in the lab as well. |
|
Excellent :) |
|
Also improved on Arm64. dotnet/perf-autofiling-issues#75 |
Uh oh!
There was an error while loading. Please reload this page.