@@ -11,7 +11,7 @@ namespace RabbitMQ.Benchmarks
11
11
[ BenchmarkCategory ( "Methods" ) ]
12
12
public class MethodSerializationBase
13
13
{
14
- protected readonly Memory < byte > _buffer = new byte [ 1024 ] ;
14
+ public readonly Memory < byte > Buffer = new byte [ 1024 ] ;
15
15
16
16
[ GlobalSetup ]
17
17
public virtual void SetUp ( ) { }
@@ -20,13 +20,13 @@ public virtual void SetUp() { }
20
20
public class MethodBasicAck : MethodSerializationBase
21
21
{
22
22
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 ) ;
24
24
25
25
[ 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
27
27
28
28
[ Benchmark ]
29
- public int BasicAckWrite ( ) => _basicAck . WriteTo ( _buffer . Span ) ;
29
+ public int BasicAckWrite ( ) => _basicAck . WriteTo ( Buffer . Span ) ;
30
30
}
31
31
32
32
public class MethodBasicDeliver : MethodSerializationBase
@@ -37,21 +37,21 @@ public class MethodBasicDeliver : MethodSerializationBase
37
37
38
38
public override void SetUp ( )
39
39
{
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 ) ;
45
45
}
46
46
47
47
[ 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
49
49
50
50
[ Benchmark ]
51
- public int BasicPublishWrite ( ) => _basicPublish . WriteTo ( _buffer . Span ) ;
51
+ public int BasicPublishWrite ( ) => _basicPublish . WriteTo ( Buffer . Span ) ;
52
52
53
53
[ Benchmark ]
54
- public int BasicPublishMemoryWrite ( ) => _basicPublishMemory . WriteTo ( _buffer . Span ) ;
54
+ public int BasicPublishMemoryWrite ( ) => _basicPublishMemory . WriteTo ( Buffer . Span ) ;
55
55
56
56
[ Benchmark ]
57
57
public int BasicPublishSize ( ) => _basicPublish . GetRequiredBufferSize ( ) ;
@@ -64,25 +64,25 @@ public class MethodChannelClose : MethodSerializationBase
64
64
{
65
65
private readonly ChannelClose _channelClose = new ChannelClose ( 333 , string . Empty , 0099 , 2999 ) ;
66
66
67
- public override void SetUp ( ) => _channelClose . WriteTo ( _buffer . Span ) ;
67
+ public override void SetUp ( ) => _channelClose . WriteTo ( Buffer . Span ) ;
68
68
69
69
[ 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
71
71
72
72
[ Benchmark ]
73
- public int ChannelCloseWrite ( ) => _channelClose . WriteTo ( _buffer . Span ) ;
73
+ public int ChannelCloseWrite ( ) => _channelClose . WriteTo ( Buffer . Span ) ;
74
74
}
75
75
76
76
public class MethodBasicProperties : MethodSerializationBase
77
77
{
78
78
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 ) ;
80
80
81
81
[ Benchmark ]
82
- public ReadOnlyBasicProperties BasicPropertiesRead ( ) => new ReadOnlyBasicProperties ( _buffer . Span ) ;
82
+ public ReadOnlyBasicProperties BasicPropertiesRead ( ) => new ReadOnlyBasicProperties ( Buffer . Span ) ;
83
83
84
84
[ Benchmark ]
85
- public int BasicPropertiesWrite ( ) => _basicProperties . WriteTo ( _buffer . Span ) ;
85
+ public int BasicPropertiesWrite ( ) => _basicProperties . WriteTo ( Buffer . Span ) ;
86
86
87
87
[ Benchmark ]
88
88
public int BasicDeliverSize ( ) => _basicProperties . GetRequiredBufferSize ( ) ;
0 commit comments