From 5cfffba6e10c14a36f3eeca8ea19c32cfaffc901 Mon Sep 17 00:00:00 2001 From: siddontang Date: Fri, 24 Oct 2014 16:39:06 +0800 Subject: [PATCH] remove crand for benchmark --- cmd/ledis-benchmark/main.go | 7 +------ cmd/ledis-storebench/main.go | 9 ++++----- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/cmd/ledis-benchmark/main.go b/cmd/ledis-benchmark/main.go index c48e23b..dad16f2 100644 --- a/cmd/ledis-benchmark/main.go +++ b/cmd/ledis-benchmark/main.go @@ -1,7 +1,6 @@ package main import ( - crand "crypto/rand" "flag" "fmt" "github.com/siddontang/ledisdb/client/go/ledis" @@ -42,7 +41,7 @@ func bench(cmd string, f func()) { t1 := time.Now() for i := 0; i < *clients; i++ { go func() { - for i := 0; i < loop; i++ { + for j := 0; j < loop; j++ { f() } wg.Done() @@ -64,7 +63,6 @@ var kvDelBase int64 = 0 func benchSet() { f := func() { value := make([]byte, *valueSize) - crand.Read(value) n := atomic.AddInt64(&kvSetBase, 1) waitBench("set", n, value) } @@ -102,7 +100,6 @@ func benchDel() { func benchPushList() { f := func() { value := make([]byte, 100) - crand.Read(value) waitBench("rpush", "mytestlist", value) } @@ -149,7 +146,6 @@ var hashDelBase int64 = 0 func benchHset() { f := func() { value := make([]byte, 100) - crand.Read(value) n := atomic.AddInt64(&hashSetBase, 1) waitBench("hset", "myhashkey", n, value) @@ -192,7 +188,6 @@ var zsetIncrBase int64 = 0 func benchZAdd() { f := func() { member := make([]byte, 16) - crand.Read(member) n := atomic.AddInt64(&zsetAddBase, 1) waitBench("zadd", "myzsetkey", n, member) } diff --git a/cmd/ledis-storebench/main.go b/cmd/ledis-storebench/main.go index 1581419..5493ee0 100644 --- a/cmd/ledis-storebench/main.go +++ b/cmd/ledis-storebench/main.go @@ -1,7 +1,6 @@ package main import ( - crand "crypto/rand" "flag" "fmt" "github.com/siddontang/go/num" @@ -35,7 +34,7 @@ func bench(cmd string, f func()) { t1 := time.Now() for i := 0; i < *clients; i++ { go func() { - for i := 0; i < loop; i++ { + for j := 0; j < loop; j++ { f() } wg.Done() @@ -46,8 +45,9 @@ func bench(cmd string, f func()) { t2 := time.Now() - fmt.Printf("%s: %0.2f op/s, %0.2fmb/s\n", cmd, (float64(*number) / t2.Sub(t1).Seconds()), - float64(*valueSize*(*number))/(1024.0*1024.0*(t2.Sub(t1).Seconds()))) + d := t2.Sub(t1) + fmt.Printf("%s: %0.3f micros/op, %0.2fmb/s\n", cmd, float64(d.Nanoseconds()/1e3)/float64(*number), + float64((*valueSize+16)*(*number))/(1024.0*1024.0*(d.Seconds()))) } var kvSetBase int64 = 0 @@ -56,7 +56,6 @@ var kvGetBase int64 = 0 func benchSet() { f := func() { value := make([]byte, *valueSize) - crand.Read(value) n := atomic.AddInt64(&kvSetBase, 1) db.Put(num.Int64ToBytes(n), value)