add get slice for dbbench

This commit is contained in:
siddontang 2014-10-30 14:15:49 +08:00
parent 44e93ba921
commit bd9e546da4
1 changed files with 21 additions and 0 deletions

View File

@ -70,6 +70,7 @@ func benchSet() {
}
func benchGet() {
kvGetBase = 0
f := func() {
n := atomic.AddInt64(&kvGetBase, 1)
v, err := db.Get(num.Int64ToBytes(n))
@ -83,6 +84,23 @@ func benchGet() {
bench("get", f)
}
var kvGetSliceBase int64 = 0
func benchGetSlice() {
kvGetSliceBase = 0
f := func() {
n := atomic.AddInt64(&kvGetSliceBase, 1)
v, err := db.GetSlice(num.Int64ToBytes(n))
if err != nil {
println(err.Error())
} else if v != nil {
v.Free()
}
}
bench("getslice", f)
}
func setRocksDB(cfg *config.RocksDBConfig) {
cfg.BlockSize = 64 * KB
cfg.WriteBufferSize = 64 * MB
@ -147,6 +165,9 @@ func main() {
for i := 0; i < *round; i++ {
benchSet()
benchGet()
benchGetSlice()
benchGet()
benchGetSlice()
println("")
}