-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Improve Guid parsing performance for "D", "N", "B", and "P" #55792
Conversation
stephentoub
commented
Jul 16, 2021
•
edited
Loading
edited
Method | Toolchain | Mean | Error | StdDev | Ratio |
---|---|---|---|---|---|
D | \main\corerun.exe | 69.87 ns | 0.644 ns | 0.538 ns | 1.00 |
D | \pr\corerun.exe | 38.21 ns | 0.097 ns | 0.086 ns | 0.55 |
N | \main\corerun.exe | 58.43 ns | 0.838 ns | 0.700 ns | 1.00 |
N | \pr\corerun.exe | 37.97 ns | 0.207 ns | 0.173 ns | 0.65 |
B | \main\corerun.exe | 69.52 ns | 0.337 ns | 0.281 ns | 1.00 |
B | \pr\corerun.exe | 39.20 ns | 0.190 ns | 0.169 ns | 0.56 |
P | \main\corerun.exe | 69.50 ns | 0.260 ns | 0.243 ns | 1.00 |
P | \pr\corerun.exe | 39.92 ns | 0.139 ns | 0.116 ns | 0.57 |
InvalidD | \main\corerun.exe | 73.47 ns | 0.656 ns | 0.614 ns | 1.00 |
InvalidD | \pr\corerun.exe | 42.47 ns | 0.142 ns | 0.133 ns | 0.58 |
WeirdD | \main\corerun.exe | 68.45 ns | 0.214 ns | 0.190 ns | 1.00 |
WeirdD | \pr\corerun.exe | 102.44 ns | 0.643 ns | 0.537 ns | 1.50 |
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. |
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 |