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

Implement IUtf8SpanFormattable on Guid #84553

Merged
merged 1 commit into from Apr 16, 2023
Merged

Conversation

stephentoub
Copy link
Member

Contributes to #81500

Method Toolchain Mean Error StdDev Ratio
ToStringDefault \main\corerun.exe 20.916 ns 0.1870 ns 0.1658 ns 1.00
ToStringDefault \pr\corerun.exe 19.801 ns 0.1450 ns 0.1356 ns 0.95
ToStringD \main\corerun.exe 20.832 ns 0.1309 ns 0.1161 ns 1.00
ToStringD \pr\corerun.exe 19.734 ns 0.2325 ns 0.2061 ns 0.95
ToStringB \main\corerun.exe 22.033 ns 0.4315 ns 0.4036 ns 1.00
ToStringB \pr\corerun.exe 20.413 ns 0.1048 ns 0.0929 ns 0.93
ToStringN \main\corerun.exe 19.940 ns 0.4086 ns 0.7574 ns 1.00
ToStringN \pr\corerun.exe 18.084 ns 0.1087 ns 0.0964 ns 0.90
ToStringX \main\corerun.exe 47.454 ns 0.6749 ns 0.5636 ns 1.00
ToStringX \pr\corerun.exe 49.319 ns 1.0002 ns 0.9823 ns 1.04
TryFormatD \main\corerun.exe 6.860 ns 0.0993 ns 0.0880 ns 1.00
TryFormatD \pr\corerun.exe 6.529 ns 0.0294 ns 0.0260 ns 0.95
TryFormatP \main\corerun.exe 7.615 ns 0.0990 ns 0.0877 ns 1.00
TryFormatP \pr\corerun.exe 6.782 ns 0.0330 ns 0.0275 ns 0.89
TryFormatN \main\corerun.exe 6.716 ns 0.1413 ns 0.1322 ns 1.00
TryFormatN \pr\corerun.exe 5.795 ns 0.0895 ns 0.0837 ns 0.86
Utf8FormatterDefault \main\corerun.exe 10.098 ns 0.0828 ns 0.0734 ns 1.00
Utf8FormatterDefault \pr\corerun.exe 10.214 ns 0.0301 ns 0.0267 ns 1.01
Utf8FormatterD \main\corerun.exe 9.362 ns 0.0610 ns 0.0571 ns 1.00
Utf8FormatterD \pr\corerun.exe 9.558 ns 0.0709 ns 0.0663 ns 1.02
Utf8FormatterP \main\corerun.exe 9.585 ns 0.0551 ns 0.0460 ns 1.00
Utf8FormatterP \pr\corerun.exe 9.985 ns 0.0765 ns 0.0678 ns 1.04
Utf8FormatterN \main\corerun.exe 8.340 ns 0.0764 ns 0.0677 ns 1.00
Utf8FormatterN \pr\corerun.exe 8.462 ns 0.0379 ns 0.0317 ns 1.01
private Guid _guid = Guid.Parse("C0513D69-6782-48C9-9542-09E133447BF2");
private char[] _chars = new char[100];
private byte[] _bytes = new byte[100];

[Benchmark] public string ToStringDefault() => _guid.ToString();
[Benchmark] public string ToStringD() => _guid.ToString("D");
[Benchmark] public string ToStringB() => _guid.ToString("B");
[Benchmark] public string ToStringN() => _guid.ToString("N");
[Benchmark] public string ToStringX() => _guid.ToString("X");

[Benchmark] public bool TryFormatD() => _guid.TryFormat(_chars, out _, "D");
[Benchmark] public bool TryFormatP() => _guid.TryFormat(_chars, out _, "P");
[Benchmark] public bool TryFormatN() => _guid.TryFormat(_chars, out _, "N");

[Benchmark] public bool Utf8FormatterDefault() => Utf8Formatter.TryFormat(_guid, _bytes, out _);
[Benchmark] public bool Utf8FormatterD() => Utf8Formatter.TryFormat(_guid, _bytes, out _, new StandardFormat('D'));
[Benchmark] public bool Utf8FormatterP() => Utf8Formatter.TryFormat(_guid, _bytes, out _, new StandardFormat('P'));
[Benchmark] public bool Utf8FormatterN() => Utf8Formatter.TryFormat(_guid, _bytes, out _, new StandardFormat('N'));

@dotnet-issue-labeler
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost
Copy link

ghost commented Apr 10, 2023

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

Issue Details

Contributes to #81500

Method Toolchain Mean Error StdDev Ratio
ToStringDefault \main\corerun.exe 20.916 ns 0.1870 ns 0.1658 ns 1.00
ToStringDefault \pr\corerun.exe 19.801 ns 0.1450 ns 0.1356 ns 0.95
ToStringD \main\corerun.exe 20.832 ns 0.1309 ns 0.1161 ns 1.00
ToStringD \pr\corerun.exe 19.734 ns 0.2325 ns 0.2061 ns 0.95
ToStringB \main\corerun.exe 22.033 ns 0.4315 ns 0.4036 ns 1.00
ToStringB \pr\corerun.exe 20.413 ns 0.1048 ns 0.0929 ns 0.93
ToStringN \main\corerun.exe 19.940 ns 0.4086 ns 0.7574 ns 1.00
ToStringN \pr\corerun.exe 18.084 ns 0.1087 ns 0.0964 ns 0.90
ToStringX \main\corerun.exe 47.454 ns 0.6749 ns 0.5636 ns 1.00
ToStringX \pr\corerun.exe 49.319 ns 1.0002 ns 0.9823 ns 1.04
TryFormatD \main\corerun.exe 6.860 ns 0.0993 ns 0.0880 ns 1.00
TryFormatD \pr\corerun.exe 6.529 ns 0.0294 ns 0.0260 ns 0.95
TryFormatP \main\corerun.exe 7.615 ns 0.0990 ns 0.0877 ns 1.00
TryFormatP \pr\corerun.exe 6.782 ns 0.0330 ns 0.0275 ns 0.89
TryFormatN \main\corerun.exe 6.716 ns 0.1413 ns 0.1322 ns 1.00
TryFormatN \pr\corerun.exe 5.795 ns 0.0895 ns 0.0837 ns 0.86
Utf8FormatterDefault \main\corerun.exe 10.098 ns 0.0828 ns 0.0734 ns 1.00
Utf8FormatterDefault \pr\corerun.exe 10.214 ns 0.0301 ns 0.0267 ns 1.01
Utf8FormatterD \main\corerun.exe 9.362 ns 0.0610 ns 0.0571 ns 1.00
Utf8FormatterD \pr\corerun.exe 9.558 ns 0.0709 ns 0.0663 ns 1.02
Utf8FormatterP \main\corerun.exe 9.585 ns 0.0551 ns 0.0460 ns 1.00
Utf8FormatterP \pr\corerun.exe 9.985 ns 0.0765 ns 0.0678 ns 1.04
Utf8FormatterN \main\corerun.exe 8.340 ns 0.0764 ns 0.0677 ns 1.00
Utf8FormatterN \pr\corerun.exe 8.462 ns 0.0379 ns 0.0317 ns 1.01
private Guid _guid = Guid.Parse("C0513D69-6782-48C9-9542-09E133447BF2");
private char[] _chars = new char[100];
private byte[] _bytes = new byte[100];

[Benchmark] public string ToStringDefault() => _guid.ToString();
[Benchmark] public string ToStringD() => _guid.ToString("D");
[Benchmark] public string ToStringB() => _guid.ToString("B");
[Benchmark] public string ToStringN() => _guid.ToString("N");
[Benchmark] public string ToStringX() => _guid.ToString("X");

[Benchmark] public bool TryFormatD() => _guid.TryFormat(_chars, out _, "D");
[Benchmark] public bool TryFormatP() => _guid.TryFormat(_chars, out _, "P");
[Benchmark] public bool TryFormatN() => _guid.TryFormat(_chars, out _, "N");

[Benchmark] public bool Utf8FormatterDefault() => Utf8Formatter.TryFormat(_guid, _bytes, out _);
[Benchmark] public bool Utf8FormatterD() => Utf8Formatter.TryFormat(_guid, _bytes, out _, new StandardFormat('D'));
[Benchmark] public bool Utf8FormatterP() => Utf8Formatter.TryFormat(_guid, _bytes, out _, new StandardFormat('P'));
[Benchmark] public bool Utf8FormatterN() => Utf8Formatter.TryFormat(_guid, _bytes, out _, new StandardFormat('N'));
Author: stephentoub
Assignees: -
Labels:

area-System.Runtime

Milestone: 8.0.0

@stephentoub
Copy link
Member Author

This was rebased on the corelib additions and is ready for review.

@stephentoub stephentoub merged commit 4db1ed2 into dotnet:main Apr 16, 2023
167 checks passed
@stephentoub stephentoub deleted the guidutf8 branch April 16, 2023 14:31
@dotnet dotnet locked as resolved and limited conversation to collaborators May 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants