Skip to content

Commit

Permalink
Tweak benchmarks and tests a bit more
Browse files Browse the repository at this point in the history
  • Loading branch information
OoLunar committed Aug 31, 2023
1 parent 6c96e83 commit 82a2bd1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
9 changes: 5 additions & 4 deletions benchmarks/Benchmarks/HttpBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using HyperSharp.Protocol;
using HyperSharp.Results;
using Microsoft.Extensions.DependencyInjection;

namespace HyperSharp.Benchmarks.Cases
Expand All @@ -27,10 +28,10 @@ public HttpBenchmarks()
public void Setup() => _hyperServer.Start();

[GlobalCleanup]
public void Cleanup() => _hyperServer.Stop();
public async Task CleanupAsync() => await _hyperServer.StopAsync();

[WarmupCount(5), Benchmark]
public async Task HttpClientTestAsync() => await _client.GetAsync("http://localhost:8080/");
public Task HttpClientTestAsync() => _client.GetAsync("http://localhost:8080/");

[IterationSetup(Target = nameof(ParseHeadersTestAsync))]
public void HeaderIterationSetup()
Expand All @@ -40,7 +41,7 @@ public void HeaderIterationSetup()
_connection = new(stream, _hyperServer);
}

[Benchmark]
public async ValueTask ParseHeadersTestAsync() => await HyperHeaderParser.TryParseHeadersAsync(_hyperServer.Configuration.MaxHeaderSize, _connection, default);
[WarmupCount(5), Benchmark]
public ValueTask<Result<HyperContext>> ParseHeadersTestAsync() => HyperHeaderParser.TryParseHeadersAsync(_hyperServer.Configuration.MaxHeaderSize, _connection, default);
}
}
6 changes: 3 additions & 3 deletions benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ namespace HyperSharp.Benchmarks
{
public sealed class Program
{
public static void Main()
public static void Main(string[] args)
{
#if DEBUG
Summary[] summaries = BenchmarkRunner.Run(typeof(Program).Assembly, ManualConfig.CreateMinimumViable().WithOptions(ConfigOptions.DisableOptimizationsValidator).AddJob(Job.Dry));
Summary[] summaries = BenchmarkRunner.Run(typeof(Program).Assembly, ManualConfig.CreateMinimumViable().WithOptions(ConfigOptions.DisableOptimizationsValidator).AddJob(Job.Dry), args);
#else
Summary[] summaries = BenchmarkRunner.Run(typeof(Program).Assembly);
Summary[] summaries = BenchmarkRunner.Run(typeof(Program).Assembly, args: args);
#endif
Summary firstSummary = summaries[0];
File.WriteAllText("benchmark-results.md", string.Empty);
Expand Down
11 changes: 0 additions & 11 deletions tests/HyperSharp/ParseHeadersTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,6 @@ public void TestNormalizeHeaderName()
Assert.AreEqual("Content-Type", normalized);
}

/// <summary>
/// Tests indexing a header name, which skips header name normalization.
/// </summary>
[TestMethod]
public void TestNormalizeHeaderNameIndex()
{
string originalName = "content-type";
HyperHeaderCollection headerCollection = new() { { originalName, "application/json" } };
Assert.ThrowsException<KeyNotFoundException>(() => headerCollection[originalName]);
}

/// <summary>
/// Tests validating a valid header.
/// </summary>
Expand Down

0 comments on commit 82a2bd1

Please sign in to comment.