github.com/tachunwu/scale@v0.0.0-20230215135019-20d7de63a560/pkg/database/rawalloc/rawalloc_test.go (about) 1 package rawalloc 2 3 import ( 4 "fmt" 5 "testing" 6 ) 7 8 var sizes = []int{16, 100, 1024, 1024 * 10, 1024 * 100, 1024 * 1024} 9 10 func BenchmarkRawalloc(b *testing.B) { 11 for _, size := range sizes { 12 b.Run(fmt.Sprintf("rawalloc-%d", size), func(b *testing.B) { 13 for i := 0; i < b.N; i++ { 14 _ = New(size, size) 15 } 16 }) 17 } 18 } 19 20 func BenchmarkMake(b *testing.B) { 21 for _, size := range sizes { 22 b.Run(fmt.Sprintf("make-%d", size), func(b *testing.B) { 23 for i := 0; i < b.N; i++ { 24 _ = make([]byte, size) 25 } 26 }) 27 } 28 }