github.com/flower-corp/rosedb@v1.1.2-0.20230117132829-21dc4f7b319a/benchmark/kv_data.go (about) 1 package benchmark 2 3 import ( 4 "bytes" 5 "fmt" 6 "math/rand" 7 "time" 8 ) 9 10 const alphabet = "abcdefghijklmnopqrstuvwxyz0123456789" 11 12 func init() { 13 rand.Seed(time.Now().Unix()) 14 } 15 16 // GetKey length: 32 Bytes 17 func getKey(n int) []byte { 18 return []byte("kvstore-bench-key------" + fmt.Sprintf("%09d", n)) 19 } 20 21 // GetValue128B . 22 func getValue128B() []byte { 23 var str bytes.Buffer 24 for i := 0; i < 128; i++ { 25 str.WriteByte(alphabet[rand.Int()%36]) 26 } 27 return []byte(str.String()) 28 } 29 30 // GetValue4K . 31 func getValue4K() []byte { 32 var str bytes.Buffer 33 for i := 0; i < 4096; i++ { 34 str.WriteByte(alphabet[rand.Int()%36]) 35 } 36 return []byte(str.String()) 37 }