Skip to content

Improve IndexOf(char, OrdinalIgnoreCase) - #73533

Merged
EgorBo merged 2 commits into
dotnet:mainfrom
EgorBo:improve-indexof-char-oic
Aug 8, 2022
Merged

Improve IndexOf(char, OrdinalIgnoreCase)#73533
EgorBo merged 2 commits into
dotnet:mainfrom
EgorBo:improve-indexof-char-oic

Conversation

@EgorBo

Copy link
Copy Markdown
Member

A similar trick is used for IndexOf(string, OrdinalIgnoreCase) see here.

Benchmark:

usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Running;BenchmarkSwitcher.FromAssembly(typeof(Benchmarks).Assembly).Run(args);publicclassBenchmarks{conststringTestStr=".NET Runtime uses third-party libraries or other resources that may be"+" distributed under licenses different than the.NET Runtime software.";[Benchmark]publicintIndexOfDash()=>TestStr.IndexOf('-',StringComparison.OrdinalIgnoreCase);[Benchmark]publicintIndexOfL()=>TestStr.IndexOf('L',StringComparison.OrdinalIgnoreCase);[Benchmark]publicintIndexOfZ()=>TestStr.IndexOf('z',StringComparison.OrdinalIgnoreCase);}
MethodJobToolchainMeanRatio
IndexOfDashJob-GBURIF\Core_Root_base\corerun.exe16.125 ns1.00
IndexOfDashJob-DLWGWE\Core_Root\corerun.exe7.084 ns0.44
IndexOfLJob-GBURIF\Core_Root_base\corerun.exe14.907 ns1.00
IndexOfLJob-DLWGWE\Core_Root\corerun.exe5.630 ns0.38
IndexOfZJob-GBURIF\Core_Root_base\corerun.exe16.809 ns1.00
IndexOfZJob-DLWGWE\Core_Root\corerun.exe8.337 ns0.50

@ghost

ghost commented Aug 7, 2022

Copy link
Copy Markdown

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.

@ghostghost assigned EgorBoAug 7, 2022
@EgorBo
EgorBo requested a review from stephentoubAugust 7, 2022 17:40

@stephentoubstephentoub left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

…ng.cs
Co-authored-by: Stephen Toub <stoub@microsoft.com>
@ghost

ghost commented Aug 7, 2022

Copy link
Copy Markdown

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

Issue Details

A similar trick is used for IndexOf(string, OrdinalIgnoreCase) see here.

Benchmark:

usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Running;BenchmarkSwitcher.FromAssembly(typeof(Benchmarks).Assembly).Run(args);publicclassBenchmarks{conststringTestStr=".NET Runtime uses third-party libraries or other resources that may be"+" distributed under licenses different than the.NET Runtime software.";[Benchmark]publicintIndexOfDash()=>TestStr.IndexOf('-',StringComparison.OrdinalIgnoreCase);[Benchmark]publicintIndexOfL()=>TestStr.IndexOf('L',StringComparison.OrdinalIgnoreCase);[Benchmark]publicintIndexOfZ()=>TestStr.IndexOf('z',StringComparison.OrdinalIgnoreCase);}
MethodJobToolchainMeanRatio
IndexOfDashJob-GBURIF\Core_Root_base\corerun.exe16.125 ns1.00
IndexOfDashJob-DLWGWE\Core_Root\corerun.exe7.084 ns0.44
IndexOfLJob-GBURIF\Core_Root_base\corerun.exe14.907 ns1.00
IndexOfLJob-DLWGWE\Core_Root\corerun.exe5.630 ns0.38
IndexOfZJob-GBURIF\Core_Root_base\corerun.exe16.809 ns1.00
IndexOfZJob-DLWGWE\Core_Root\corerun.exe8.337 ns0.50
Author:EgorBo
Assignees:EgorBo
Labels:

area-System.Runtime

Milestone:-

@EgorBo

Copy link
Copy Markdown
MemberAuthor

Failure is #73247

@EgorBo
EgorBo merged commit bee3953 into dotnet:mainAug 8, 2022
@adamsitnikadamsitnik added the tenet-performance Performance related issue label Aug 8, 2022
@ghostghost locked as resolved and limited conversation to collaborators Sep 7, 2022
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Runtimetenet-performancePerformance related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@EgorBo@stephentoub@adamsitnik@danmoseley