Skip to content

Conversation

@EgorBo
Copy link
Member

@EgorBo EgorBo commented Jul 24, 2022

Use Equals instead of Compare. The same method is used for String.StartsWith

static readonly string TestStr = typeof(object).Assembly.Location;

[Benchmark]
public bool EndsWith_small() => 
    TestStr.EndsWith(".DLL", StringComparison.OrdinalIgnoreCase);

[Benchmark]
public bool EndsWith_large() => 
    TestStr.EndsWith("system.private.corelib.dll", StringComparison.OrdinalIgnoreCase);
Method Toolchain Mean Error StdDev Ratio
EndsWith_small \Core_Root\corerun.exe 4.502 ns 0.0076 ns 0.0064 ns 0.54
EndsWith_small \Core_Root_base\corerun.exe 8.368 ns 0.0113 ns 0.0106 ns 1.00
EndsWith_large \Core_Root\corerun.exe 12.669 ns 0.0456 ns 0.0404 ns 0.60
EndsWith_large \Core_Root_base\corerun.exe 21.006 ns 0.0429 ns 0.0358 ns 1.00

@ghost
Copy link

ghost commented Jul 24, 2022

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.

@ghost ghost assigned EgorBo Jul 24, 2022
@EgorBo EgorBo merged commit e83493e into dotnet:main Jul 25, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Aug 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants