Commit fcc1a079 authored by luxq's avatar luxq

update test

parent 96b623d9
...@@ -473,11 +473,11 @@ func BenchmarkDbWorkerRunning_FindWorkerByModelId(b *testing.B) { ...@@ -473,11 +473,11 @@ func BenchmarkDbWorkerRunning_FindWorkerByModelId(b *testing.B) {
defer db.client.Disconnect(context.Background()) defer db.client.Disconnect(context.Background())
b.ResetTimer() b.ResetTimer()
for i := 0; i < b.N; i++ { for i := 0; i < b.N; i++ {
modelId := getRandIdInt(100) modelId := getRandIdInt(maxModelId)
if w, err := db.FindWorkerByModelId(context.Background(), modelId, 10); err != nil { if w, err := db.FindWorkerByModelId(context.Background(), modelId, 10); err != nil {
panic(fmt.Sprintf("find worker failed with err:%s", err)) panic(fmt.Sprintf("find worker failed with err:%s", err))
} else if len(w) == 0 { } else if len(w) == 0 {
b.Logf("FindWorkerByModelId find %d with id %s\n", len(w), modelId) b.Logf("FindWorkerByModelId find %d with id %d\n", len(w), modelId)
} }
} }
} }
...@@ -491,11 +491,11 @@ func BenchmarkDbWorkerRunning_FindWorkerByModelId_Parallel(b *testing.B) { ...@@ -491,11 +491,11 @@ func BenchmarkDbWorkerRunning_FindWorkerByModelId_Parallel(b *testing.B) {
defer db.client.Disconnect(context.Background()) defer db.client.Disconnect(context.Background())
b.RunParallel(func(pb *testing.PB) { b.RunParallel(func(pb *testing.PB) {
for pb.Next() { for pb.Next() {
modelId := getRandIdInt(100) modelId := getRandIdInt(maxModelId)
if w, err := db.FindWorkerByModelId(context.Background(), modelId, 10); err != nil { if w, err := db.FindWorkerByModelId(context.Background(), modelId, 10); err != nil {
panic(fmt.Sprintf("find worker failed with err:%s", err)) panic(fmt.Sprintf("find worker failed with err:%s", err))
} else if len(w) == 0 { } else if len(w) == 0 {
b.Logf("FindWorkerByModelId find %d with id %s\n", len(w), modelId) b.Logf("FindWorkerByModelId find %d with id %d\n", len(w), modelId)
} }
} }
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment