Skip to content

TryAddWithoutValidation for multiple values could be more efficient - #4240

Open
pedrobsaila wants to merge 3 commits into
dotnet:mainfrom
pedrobsaila:64049
Open

pedrobsaila wants to merge 3 commits into
dotnet:mainfrom
pedrobsaila:64049

Conversation

@pedrobsaila

Copy link
Copy Markdown

Contributes to dotnet/runtime#64049

@MihaZupan MihaZupan 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.

Thank you for the improving coverage here

namespace System.Net.Http.Tests
{
[BenchmarkCategory(Categories.Libraries, Categories.LINQ)]
public class TryAddWithoutValidationTests

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.

Please make a new class for HttpHeaders instead, with this being one of the tested methods there


namespace System.Net.Http.Tests
{
[BenchmarkCategory(Categories.Libraries, Categories.LINQ)]

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.

Suggested change
[BenchmarkCategory(Categories.Libraries, Categories.LINQ)]
[BenchmarkCategory(Categories.Libraries)]

{
[Benchmark]
[ArgumentsSource(nameof(IEnumerableArgument))]
public bool AddHeaders(AddWithoutValidationTestData data) => new HttpResponseMessage().Headers.TryAddWithoutValidation("headerName", data.Values);

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.

We could make the test more focused on just the adding part, e.g.

private readonly HttpResponseHeaders _responseHeaders = new HttpResponseMessage().Headers;

public bool SomeTest()
{
    _responseHeaders.Add(...);
    _responseHeaders.Clear();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants