Add more benchmarks?
This commit is contained in:
@@ -292,7 +292,6 @@ func TestEncodeIntoWithBoundaryValues(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// region decode
|
||||
func TestDecodeHandlesShortByteSlice(t *testing.T) {
|
||||
var p PDU_HEADER
|
||||
@@ -463,7 +462,26 @@ func BenchmarkEncode(b *testing.B) {
|
||||
}
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
p.Encode()
|
||||
buf, _ := p.Encode()
|
||||
ByteBufferPool.Put(buf)
|
||||
}
|
||||
}
|
||||
|
||||
// These two are effectively the same but there is difference in execution time
|
||||
// I wonder why...
|
||||
// I should stop writing benchmarks...
|
||||
func BenchmarkEncodeWithBufferPool(b *testing.B) {
|
||||
p := &PDU_HEADER{
|
||||
command_length: 16,
|
||||
command_id: 1,
|
||||
command_status: 0,
|
||||
sequence_number: 12345,
|
||||
}
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
buf := ByteBufferPool.Get(uint(p.Size()))
|
||||
p.EncodeInto(buf)
|
||||
ByteBufferPool.Put(buf)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -489,4 +507,4 @@ func BenchmarkDecode(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
p.Decode(data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user