Browse Source

add a setWithJson test

Xiang Li 12 years ago
parent
commit
c2d1dc4f51
1 changed files with 19 additions and 0 deletions
  1. 19 0
      store/store_bench_test.go

+ 19 - 0
store/store_bench_test.go

@@ -17,6 +17,7 @@ limitations under the License.
 package store
 
 import (
+	"encoding/json"
 	"fmt"
 	"math/rand"
 	"testing"
@@ -36,6 +37,24 @@ func BenchmarkStoreSet(b *testing.B) {
 	}
 }
 
+func BenchmarkStoreSetWithJson(b *testing.B) {
+	s := newStore()
+	b.StopTimer()
+	kvs := generateNRandomKV(b.N)
+	b.StartTimer()
+
+	for i := 0; i < b.N; i++ {
+		resp, err := s.Set(kvs[i][0], false, kvs[i][1], Permanent)
+		if err != nil {
+			panic(err)
+		}
+		_, err = json.Marshal(resp)
+		if err != nil {
+			panic(err)
+		}
+	}
+}
+
 func generateNRandomKV(n int) [][]string {
 	kvs := make([][]string, n)