From bd9e546da4399d3b3892999e689e97a994f33122 Mon Sep 17 00:00:00 2001 From: siddontang Date: Thu, 30 Oct 2014 14:15:49 +0800 Subject: [PATCH] add get slice for dbbench --- cmd/ledis-dbbench/main.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/cmd/ledis-dbbench/main.go b/cmd/ledis-dbbench/main.go index bfacc4c..b2183ce 100644 --- a/cmd/ledis-dbbench/main.go +++ b/cmd/ledis-dbbench/main.go @@ -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("") }