@@ -11,7 +11,7 @@ namespace RabbitMQ.Benchmarks
1111 [ BenchmarkCategory ( "Methods" ) ]
1212 public class MethodSerializationBase
1313 {
14- protected readonly Memory < byte > _buffer = new byte [ 1024 ] ;
14+ public readonly Memory < byte > Buffer = new byte [ 1024 ] ;
1515
1616 [ GlobalSetup ]
1717 public virtual void SetUp ( ) { }
@@ -20,13 +20,13 @@ public virtual void SetUp() { }
2020 public class MethodBasicAck : MethodSerializationBase
2121 {
2222 private readonly BasicAck _basicAck = new BasicAck ( ulong . MaxValue , true ) ;
23- public override void SetUp ( ) => _basicAck . WriteTo ( _buffer . Span ) ;
23+ public override void SetUp ( ) => _basicAck . WriteTo ( Buffer . Span ) ;
2424
2525 [ Benchmark ]
26- public ulong BasicAckRead ( ) => new BasicAck ( _buffer . Span ) . _deliveryTag ; // return one property to not box when returning an object instead
26+ public ulong BasicAckRead ( ) => new BasicAck ( Buffer . Span ) . _deliveryTag ; // return one property to not box when returning an object instead
2727
2828 [ Benchmark ]
29- public int BasicAckWrite ( ) => _basicAck . WriteTo ( _buffer . Span ) ;
29+ public int BasicAckWrite ( ) => _basicAck . WriteTo ( Buffer . Span ) ;
3030 }
3131
3232 public class MethodBasicDeliver : MethodSerializationBase
@@ -37,21 +37,21 @@ public class MethodBasicDeliver : MethodSerializationBase
3737
3838 public override void SetUp ( )
3939 {
40- int offset = Client . Impl . WireFormatting . WriteShortstr ( ref _buffer . Span . GetStart ( ) , string . Empty ) ;
41- offset += Client . Impl . WireFormatting . WriteLonglong ( ref _buffer . Span . GetOffset ( offset ) , 0 ) ;
42- offset += Client . Impl . WireFormatting . WriteBits ( ref _buffer . Span . GetOffset ( offset ) , false ) ;
43- offset += Client . Impl . WireFormatting . WriteShortstr ( ref _buffer . Span . GetOffset ( offset ) , string . Empty ) ;
44- Client . Impl . WireFormatting . WriteShortstr ( ref _buffer . Span . GetOffset ( offset ) , string . Empty ) ;
40+ int offset = Client . Impl . WireFormatting . WriteShortstr ( ref Buffer . Span . GetStart ( ) , string . Empty ) ;
41+ offset += Client . Impl . WireFormatting . WriteLonglong ( ref Buffer . Span . GetOffset ( offset ) , 0 ) ;
42+ offset += Client . Impl . WireFormatting . WriteBits ( ref Buffer . Span . GetOffset ( offset ) , false ) ;
43+ offset += Client . Impl . WireFormatting . WriteShortstr ( ref Buffer . Span . GetOffset ( offset ) , string . Empty ) ;
44+ Client . Impl . WireFormatting . WriteShortstr ( ref Buffer . Span . GetOffset ( offset ) , string . Empty ) ;
4545 }
4646
4747 [ Benchmark ]
48- public object BasicDeliverRead ( ) => new BasicDeliver ( _buffer ) . _consumerTag ; // return one property to not box when returning an object instead
48+ public object BasicDeliverRead ( ) => new BasicDeliver ( Buffer ) . _consumerTag ; // return one property to not box when returning an object instead
4949
5050 [ Benchmark ]
51- public int BasicPublishWrite ( ) => _basicPublish . WriteTo ( _buffer . Span ) ;
51+ public int BasicPublishWrite ( ) => _basicPublish . WriteTo ( Buffer . Span ) ;
5252
5353 [ Benchmark ]
54- public int BasicPublishMemoryWrite ( ) => _basicPublishMemory . WriteTo ( _buffer . Span ) ;
54+ public int BasicPublishMemoryWrite ( ) => _basicPublishMemory . WriteTo ( Buffer . Span ) ;
5555
5656 [ Benchmark ]
5757 public int BasicPublishSize ( ) => _basicPublish . GetRequiredBufferSize ( ) ;
@@ -64,25 +64,25 @@ public class MethodChannelClose : MethodSerializationBase
6464 {
6565 private readonly ChannelClose _channelClose = new ChannelClose ( 333 , string . Empty , 0099 , 2999 ) ;
6666
67- public override void SetUp ( ) => _channelClose . WriteTo ( _buffer . Span ) ;
67+ public override void SetUp ( ) => _channelClose . WriteTo ( Buffer . Span ) ;
6868
6969 [ Benchmark ]
70- public object ChannelCloseRead ( ) => new ChannelClose ( _buffer . Span ) . _replyText ; // return one property to not box when returning an object instead
70+ public object ChannelCloseRead ( ) => new ChannelClose ( Buffer . Span ) . _replyText ; // return one property to not box when returning an object instead
7171
7272 [ Benchmark ]
73- public int ChannelCloseWrite ( ) => _channelClose . WriteTo ( _buffer . Span ) ;
73+ public int ChannelCloseWrite ( ) => _channelClose . WriteTo ( Buffer . Span ) ;
7474 }
7575
7676 public class MethodBasicProperties : MethodSerializationBase
7777 {
7878 private readonly IAmqpWriteable _basicProperties = new BasicProperties { Persistent = true , AppId = "AppId" , ContentEncoding = "content" , } ;
79- public override void SetUp ( ) => _basicProperties . WriteTo ( _buffer . Span ) ;
79+ public override void SetUp ( ) => _basicProperties . WriteTo ( Buffer . Span ) ;
8080
8181 [ Benchmark ]
82- public ReadOnlyBasicProperties BasicPropertiesRead ( ) => new ReadOnlyBasicProperties ( _buffer . Span ) ;
82+ public ReadOnlyBasicProperties BasicPropertiesRead ( ) => new ReadOnlyBasicProperties ( Buffer . Span ) ;
8383
8484 [ Benchmark ]
85- public int BasicPropertiesWrite ( ) => _basicProperties . WriteTo ( _buffer . Span ) ;
85+ public int BasicPropertiesWrite ( ) => _basicProperties . WriteTo ( Buffer . Span ) ;
8686
8787 [ Benchmark ]
8888 public int BasicDeliverSize ( ) => _basicProperties . GetRequiredBufferSize ( ) ;
0 commit comments