Files
DotNetty/test/DotNetty.Microbench/Http/HttpRequestEncoderInsertBenchmark.cs
Andrey Ilnitsky 1cdaadbfaa - target net472 and netstandard2.0
- microsoft.extensions.logging 5.0.0
- microsoft.extensions.configuration 5.0.0
2021-07-16 18:04:31 -07:00

44 lines
1.3 KiB
C#

// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace DotNetty.Microbench.Http
{
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using DotNetty.Buffers;
using DotNetty.Codecs.Http;
using DotNetty.Common;
[SimpleJob(RuntimeMoniker.NetCoreApp31)]
[BenchmarkCategory("Http")]
public class HttpRequestEncoderInsertBenchmark
{
string uri;
HttpRequestEncoder encoder;
[GlobalSetup]
public void GlobalSetup()
{
ResourceLeakDetector.Level = ResourceLeakDetector.DetectionLevel.Disabled;
this.uri = "http://localhost?eventType=CRITICAL&from=0&to=1497437160327&limit=10&offset=0";
this. encoder = new HttpRequestEncoder();
}
[Benchmark]
public IByteBuffer EncodeInitialLine()
{
IByteBuffer buffer = Unpooled.Buffer(100);
try
{
this.encoder.EncodeInitialLine(buffer, new DefaultHttpRequest(HttpVersion.Http11,
HttpMethod.Get,this.uri));
return buffer;
}
finally
{
buffer.Release();
}
}
}
}