1+ using Akka . Actor ;
12using BenchmarkDotNet . Attributes ;
23using TurboHTTP . MicroBenchmarks . Internal ;
3- using TurboHTTP . Protocol . Http10 ;
4+ using TurboHTTP . Protocol . Syntax . Http10 ;
5+ using TurboHTTP . Protocol . Syntax . Http10 . Client ;
6+ using TurboHTTP . Protocol . Syntax . Http10 . Options ;
47
58namespace TurboHTTP . MicroBenchmarks . Http10 ;
69
@@ -10,6 +13,7 @@ public class Http10EncoderBenchmark
1013 private HttpRequestMessage _simpleGet = null ! ;
1114 private HttpRequestMessage _requestWithHeaders = null ! ;
1215 private byte [ ] _buffer = null ! ;
16+ private Http10ClientEncoder _encoder = null ! ;
1317
1418 [ GlobalSetup ]
1519 public void Setup ( )
@@ -24,19 +28,21 @@ public void Setup()
2428 _requestWithHeaders . Headers . TryAddWithoutValidation ( "X-Request-Id" , "bench-001" ) ;
2529 _requestWithHeaders . Headers . TryAddWithoutValidation ( "Cache-Control" , "no-cache" ) ;
2630 _requestWithHeaders . Content = new ByteArrayContent ( new byte [ 256 ] ) ;
31+
32+ _encoder = new Http10ClientEncoder ( Http10ClientEncoderOptions . Default , Http10Profile . Default ) ;
2733 }
2834
2935 [ Benchmark ( Baseline = true ) ]
3036 public int EncodeSimpleGet ( )
3137 {
3238 var span = _buffer . AsSpan ( ) ;
33- return Encoder . Encode ( _simpleGet , ref span ) ;
39+ return _encoder . Encode ( span , _simpleGet , ActorRefs . Nobody ) ;
3440 }
3541
3642 [ Benchmark ]
3743 public int EncodeWithHeaders ( )
3844 {
3945 var span = _buffer . AsSpan ( ) ;
40- return Encoder . Encode ( _requestWithHeaders , ref span ) ;
46+ return _encoder . Encode ( span , _requestWithHeaders , ActorRefs . Nobody ) ;
4147 }
4248}
0 commit comments