add a setWithJson test

This commit is contained in:
Xiang Li
2014-01-16 09:16:33 +08:00
parent 77477b3e43
commit c2d1dc4f51

View File

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