mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
fix bench
This commit is contained in:
parent
cc88215b46
commit
ddcf3975ed
@ -8,23 +8,19 @@ import (
|
||||
"github.com/coreos/go-etcd/etcd"
|
||||
)
|
||||
|
||||
func doWrite(client *etcd.Client, key string, c chan int) {
|
||||
client.Set(key, key, 0)
|
||||
c <- 1
|
||||
}
|
||||
|
||||
func write(client *etcd.Client, requests int, end chan int) {
|
||||
c := make(chan int)
|
||||
func write(requests int, end chan int) {
|
||||
client := etcd.NewClient(nil)
|
||||
|
||||
for i := 0; i < requests; i++ {
|
||||
key := strconv.Itoa(i)
|
||||
go doWrite(client, key, c)
|
||||
<-c
|
||||
client.Set(key, key, 0)
|
||||
}
|
||||
end <- 1
|
||||
}
|
||||
|
||||
func watch(client *etcd.Client, key string) {
|
||||
func watch(key string) {
|
||||
client := etcd.NewClient(nil)
|
||||
|
||||
receiver := make(chan *etcd.Response)
|
||||
go client.Watch(key, 0, true, receiver, nil)
|
||||
|
||||
@ -45,16 +41,14 @@ func main() {
|
||||
|
||||
flag.Parse()
|
||||
|
||||
client := etcd.NewClient(nil)
|
||||
|
||||
for i := 0; i < *watches; i++ {
|
||||
key := strconv.Itoa(i)
|
||||
go watch(client, key)
|
||||
go watch(key)
|
||||
}
|
||||
|
||||
wChan := make(chan int, *cWrites)
|
||||
for i := 0; i < *cWrites; i++ {
|
||||
go write(client, (*rWrites / *cWrites), wChan)
|
||||
go write((*rWrites / *cWrites), wChan)
|
||||
}
|
||||
|
||||
for i := 0; i < *cWrites; i++ {
|
||||
|
Loading…
x
Reference in New Issue
Block a user