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

TryAddWithoutValidation for multiple values could be more efficient #4240

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

pedrobsaila
Copy link

Contributes to dotnet/runtime#64049

Copy link
Member

@MihaZupan MihaZupan left a comment

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
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
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
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