benchmark buffer pointer vs value

pull/314/head
Darien Raymond 2016-12-08 17:39:15 +01:00
parent 0e515f401c
commit 316b4f2025
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 22 additions and 0 deletions

View File

@ -81,3 +81,25 @@ func BenchmarkNewLocalBuffer2048(b *testing.B) {
buffer.Release()
}
}
func BenchmarkBufferValue(b *testing.B) {
x := Buffer{}
doSomething := func(a Buffer) {
_ = a.Len()
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
doSomething(x)
}
}
func BenchmarkBufferPointer(b *testing.B) {
x := NewSmallBuffer()
doSomething := func(a *Buffer) {
_ = a.Len()
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
doSomething(x)
}
}