remove crand for benchmark

This commit is contained in:
siddontang 2014-10-24 16:39:06 +08:00
parent e0124cb64a
commit 5cfffba6e1
2 changed files with 5 additions and 11 deletions

View File

@ -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)
}

View File

@ -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)