benchmark buffer pointer vs value

pull/314/head
Darien Raymond 8 years ago
parent 0e515f401c
commit 316b4f2025
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169

@ -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)
}
}

Loading…
Cancel
Save