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

Longer strings for string.Replace(char, char) benchmarks #2329

Merged
merged 3 commits into from
Mar 24, 2022

Conversation

gfoidl
Copy link
Member

@gfoidl gfoidl commented Mar 23, 2022

Copy link
Member Author

@gfoidl gfoidl left a comment

Choose a reason for hiding this comment

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

Notes for review.

public string Replace_Char(string text, char oldChar, char newChar)
=> text.Replace(oldChar, newChar);

public static IEnumerable<object[]> ReplaceArguments()
Copy link
Member Author

Choose a reason for hiding this comment

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

Verifyed that the method names are displayed the same way, so that the reporting tool has correlation. Is this enough to be on the safe side here?

|          Method |                 text | oldChar | newChar |       Mean |      Error |    StdDev |
|---------------- |--------------------- |-------- |-------- |-----------:|-----------:|----------:|
| Replace_CharNew |  ----(...)---- [100] |       - |       + |  32.553 ns |  21.554 ns | 1.1815 ns |
| Replace_CharNew | ----(...)---- [1000] |       - |       + | 202.048 ns | 178.291 ns | 9.7727 ns |
|    Replace_Char |                Hello |       a |       b |   5.256 ns |   4.023 ns | 0.2205 ns |
| Replace_CharNew |                Hello |       a |       b |   5.367 ns |   2.158 ns | 0.1183 ns |
|    Replace_Char |                Hello |       l |       ! |  17.491 ns |   4.643 ns | 0.2545 ns |
| Replace_CharNew |                Hello |       l |       ! |  18.092 ns |  12.480 ns | 0.6841 ns |
|    Replace_Char | This (...)tence [28] |       i |       I |  36.695 ns |  91.723 ns | 5.0277 ns |
| Replace_CharNew | This (...)tence [28] |       i |       I |  30.385 ns |  25.207 ns | 1.3817 ns |
|    Replace_Char | This (...)tence [28] |       z |       y |  11.598 ns |   6.366 ns | 0.3489 ns |
| Replace_CharNew | This (...)tence [28] |       z |       y |  12.132 ns |  10.304 ns | 0.5648 ns |

The ones with suffix New are the methods with the ArgumentsSource, the other ones with Arguments only (as in main-branch).

Copy link
Member

Choose a reason for hiding this comment

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

@adamsitnik @DrewScoggins can you confirm this won't reset the results?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I thought I had already responded here. As long as the test name or the arguments have not changed values we should have no issues here. And from what I can tell nothing has changed for the existing test cases. So this LGTM.

Copy link
Member

@danmoseley danmoseley left a comment

Choose a reason for hiding this comment

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

LGTM once we get an answer to q above. thanks for adding these.

@DrewScoggins DrewScoggins merged commit 38fcdf0 into dotnet:main Mar 24, 2022
@gfoidl gfoidl deleted the string_replace_char_longer branch March 25, 2022 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants