mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
add a setWithJson test
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user