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

Investigate perf gain by using the .NET char comparison pattern #1915

Open
daxian-dbw opened this issue Oct 30, 2020 · 3 comments
Open

Investigate perf gain by using the .NET char comparison pattern #1915

daxian-dbw opened this issue Oct 30, 2020 · 3 comments
Labels
Issue-Enhancement It's a feature request. Not-Planned

Comments

@daxian-dbw
Copy link
Member

Description of the new feature/enhancement

This is a follow-up issue tracking the discussion in #1909 (comment).
We can investigate to see if we can get some perf gain by using the .NET char comparison pattern, such as in https://source.dot.net/#System.Private.CoreLib/UnicodeUtility.cs,141

@daxian-dbw daxian-dbw added the Issue-Enhancement It's a feature request. label Oct 30, 2020
@ghost ghost added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Oct 30, 2020
@iSazonov
Copy link

Do you want to measure only LengthInBufferCells() method?
I could measure and share results if you want.

@daxian-dbw
Copy link
Member Author

Yup, measuring only the LengthInBufferCells() would be enough. Thanks!

@daxian-dbw daxian-dbw added Not-Planned and removed Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. labels Oct 30, 2020
@iSazonov
Copy link

In my test the worst case (char is in last range) is improved up to 16%. Thoughts?

BenchmarkDotNet=v0.12.1, OS=Windows 10.0.18362.1082 (1903/May2019Update/19H1)
Intel Core i5-2410M CPU 2.30GHz (Sandy Bridge), 1 CPU, 4 logical and 2 physical cores
.NET Core SDK=5.0.100-rc.2.20479.15
  [Host]     : .NET Core 5.0.0 (CoreCLR 5.0.20.47505, CoreFX 5.0.20.47505), X64 RyuJIT
  DefaultJob : .NET Core 5.0.0 (CoreCLR 5.0.20.47505, CoreFX 5.0.20.47505), X64 RyuJIT

Method InputString Mean Error StdDev Ratio Gen 0 Gen 1 Gen 2 Allocated Code Size
LengthOrig ï¿¡ 8.059 ns 0.0812 ns 0.0759 ns 1.00 - - - - 251 B
LengthNew ï¿¡ 6.757 ns 0.0846 ns 0.0791 ns 0.84 - - - - 206 B

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement It's a feature request. Not-Planned
Projects
None yet
Development

No branches or pull requests

2 participants