mirror of https://github.com/v2ray/v2ray-core
benchmark buffer pointer vs value
parent
0e515f401c
commit
316b4f2025
|
@ -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…
Reference in New Issue