mirror of
https://github.com/charlienet/go-mixed.git
synced 2025-07-18 00:22:41 +08:00
byte cache
This commit is contained in:
@ -1,11 +0,0 @@
|
||||
package bytecache
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestByteCache(t *testing.T) {
|
||||
bp := NewBytePool(512, 1024, 1024)
|
||||
buffer := bp.Get()
|
||||
defer bp.Put(buffer)
|
||||
|
||||
t.Log(len(buffer))
|
||||
}
|
28
byte_cache/byte_cache_test.go
Normal file
28
byte_cache/byte_cache_test.go
Normal file
@ -0,0 +1,28 @@
|
||||
package bytecache
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestByteCache(t *testing.T) {
|
||||
bp := NewBytePool(512, 1024, 1024)
|
||||
buffer := bp.Get()
|
||||
defer bp.Put(buffer)
|
||||
|
||||
t.Log(len(buffer))
|
||||
}
|
||||
|
||||
func BenchmarkByteCache(b *testing.B) {
|
||||
bp := NewBytePool(512, 1024, 1024)
|
||||
b.Run("aaaaa", func(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
bp.Put(bp.Get())
|
||||
}
|
||||
})
|
||||
|
||||
b.Run("bbbb", func(b *testing.B) {
|
||||
for i := 0; i < b.N; i++ {
|
||||
a := make([]byte, 1024)
|
||||
|
||||
a[0] = 1
|
||||
}
|
||||
})
|
||||
}
|
Reference in New Issue
Block a user