bench: retry when creating keys

This commit is contained in:
Gyu-Ho Lee 2016-03-21 04:24:11 -07:00
parent 3a063ce897
commit 4d2a16638f
3 changed files with 51 additions and 17 deletions

View File

@ -1,3 +1,17 @@
// Copyright 2016 CoreOS, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
@ -35,6 +49,10 @@ func main() {
tableToMemoryIdx := make(map[int]int)
maxSize := 0
var compareColumns = map[string]int{
"second": 0,
}
initSize := len(compareColumns)
for i, prefix := range prefixes {
tb, err := combine(prefix)
if err != nil {
@ -59,19 +77,13 @@ func main() {
if maxSize < len(tb.Rows) {
maxSize = len(tb.Rows)
}
}
// second, avg_latency_ms, throughput, avg_cpu, avg_memory_mb
var compareColumns = map[string]int{
"second": 0,
}
initSize := len(compareColumns)
for i := range tbs {
compareColumns["avg_latency_ms_"+tableToSuffix[i]] = 4*i + initSize
compareColumns["throughput_"+tableToSuffix[i]] = 4*i + initSize + 1
compareColumns["avg_cpu_"+tableToSuffix[i]] = 4*i + initSize + 2
compareColumns["avg_memory_mb_"+tableToSuffix[i]] = 4*i + initSize + 3
}
columnSlice := make([]string, len(compareColumns))
for k, v := range compareColumns {
columnSlice[v] = k
@ -99,6 +111,10 @@ func main() {
log.Fatal(err)
}
log.Printf("Successfully saved compared.csv")
// TODO:
// add etcd2, consul
// add plotting
}
func combine(prefix string) (ps.Table, error) {

View File

@ -28,7 +28,7 @@ import (
// This represents the base command when called without any subcommands
var Command = &cobra.Command{
Use: "bench",
Short: "Low-level benchmark tool for etcd, Zookeeper.",
Short: "Low-level benchmark tool for etcd, Zookeeper, etcd2, consul.",
}
var (

View File

@ -58,23 +58,41 @@ func rangeFunc(cmd *cobra.Command, args []string) {
switch database {
case "etcd":
fmt.Printf("PUT '%s' to etcd\n", k)
clients := mustCreateClients(1, 1)
_, err := clients[0].Do(context.Background(), v3.OpPut(k, string(v)))
if err != nil {
var cerr error
for i := 0; i < 5; i++ {
clients := mustCreateClients(1, 1)
_, cerr = clients[0].Do(context.Background(), v3.OpPut(k, string(v)))
if cerr != nil {
continue
}
fmt.Printf("Done with PUT '%s' to etcd\n", k)
break
}
if cerr != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Printf("Done with PUT '%s' to etcd\n", k)
case "zk":
k = "/" + k
fmt.Printf("PUT '%s' to zookeeper\n", k)
conns := mustCreateConnsZk(totalConns)
_, err := conns[0].Create(k, v, zkCreateFlags, zkCreateAcl)
if err != nil {
fmt.Printf("PUT '%s' to Zookeeper\n", k)
var cerr error
for i := 0; i < 5; i++ {
conns := mustCreateConnsZk(totalConns)
_, cerr = conns[0].Create(k, v, zkCreateFlags, zkCreateAcl)
if cerr != nil {
continue
}
fmt.Printf("Done with PUT '%s' to Zookeeper\n", k)
break
}
if cerr != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Printf("Done with PUT '%s' to zookeeper\n", k)
}
} else if len(args) == 0 || len(args) > 2 {
fmt.Fprintln(os.Stderr, cmd.Usage())