fix test file

This commit is contained in:
Xiang Li 2013-08-05 21:28:42 -07:00
parent d239e5e0dd
commit 65c34457de
3 changed files with 14 additions and 23 deletions

View File

@ -150,7 +150,7 @@ func BenchmarkStoreSet(b *testing.B) {
func BenchmarkStoreGet(b *testing.B) { func BenchmarkStoreGet(b *testing.B) {
s := CreateStore(100) s := CreateStore(100)
keys := GenKeys(100, 5) keys := GenKeys(10000, 5)
for i, key := range keys { for i, key := range keys {
s.Set(key, "barbarbarbarbar", time.Unix(0, 0), uint64(i)) s.Set(key, "barbarbarbarbar", time.Unix(0, 0), uint64(i))

View File

@ -11,7 +11,7 @@ func GenKeys(num int, depth int) []string {
for i := 0; i < num; i++ { for i := 0; i < num; i++ {
keys[i] = "/foo/" keys[i] = "/foo/"
depth := rand.Intn(depth) depth := rand.Intn(depth) + 1
for j := 0; j < depth; j++ { for j := 0; j < depth; j++ {
keys[i] += "/" + strconv.Itoa(rand.Int()) keys[i] += "/" + strconv.Itoa(rand.Int())

View File

@ -1,7 +1,7 @@
package store package store
import ( import (
"fmt" //"fmt"
"math/rand" "math/rand"
"strconv" "strconv"
"testing" "testing"
@ -64,20 +64,20 @@ func TestStoreGet(t *testing.T) {
ts.set("/hello/fooo", NewTestNode("barbarbar")) ts.set("/hello/fooo", NewTestNode("barbarbar"))
ts.set("/hello/foooo/foo", NewTestNode("barbarbar")) ts.set("/hello/foooo/foo", NewTestNode("barbarbar"))
nodes, keys, ok := ts.list("/hello") //nodes, keys, ok := ts.list("/hello")
if !ok { // if !ok {
t.Fatalf("cannot list!") // t.Fatalf("cannot list!")
} else { // } else {
nodes, _ := nodes.([]*Node) // nodes, _ := nodes.([]*Node)
length := len(nodes) // length := len(nodes)
for i := 0; i < length; i++ { // for i := 0; i < length; i++ {
fmt.Println(keys[i], "=", nodes[i].Value) // fmt.Println(keys[i], "=", nodes[i].Value)
} // }
} // }
keys = GenKeys(100, 10) keys := GenKeys(100, 10)
for i := 0; i < 100; i++ { for i := 0; i < 100; i++ {
value := strconv.Itoa(rand.Int()) value := strconv.Itoa(rand.Int())
@ -206,15 +206,6 @@ func BenchmarkTreeStoreCopy(b *testing.B) {
} }
} }
func BenchmarkMakeSlice(b *testing.B) {
for i := 0; i < b.N; i++ {
for i := 0; i < 100000; i++ {
_ = make([]Node, 1)
}
}
}
func BenchmarkTreeStoreList(b *testing.B) { func BenchmarkTreeStoreList(b *testing.B) {
keys := GenKeys(10000, 10) keys := GenKeys(10000, 10)