add error package
This commit is contained in:
@ -17,7 +17,6 @@ func main() {
|
||||
c := etcd.NewClient()
|
||||
c.Set("lock", "unlock", 0)
|
||||
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
go t(i, ch, etcd.NewClient())
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package main
|
||||
package main
|
||||
|
||||
import (
|
||||
"github.com/coreos/go-etcd/etcd"
|
||||
"fmt"
|
||||
"github.com/coreos/go-etcd/etcd"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -11,21 +11,21 @@ var count = 0
|
||||
func main() {
|
||||
ch := make(chan bool, 10)
|
||||
// set up a lock
|
||||
for i:=0; i < 100; i++ {
|
||||
for i := 0; i < 100; i++ {
|
||||
go t(i, ch, etcd.NewClient())
|
||||
}
|
||||
start := time.Now()
|
||||
for i:=0; i< 100; i++ {
|
||||
for i := 0; i < 100; i++ {
|
||||
<-ch
|
||||
}
|
||||
fmt.Println(time.Now().Sub(start), ": ", 100 * 50, "commands")
|
||||
fmt.Println(time.Now().Sub(start), ": ", 100*50, "commands")
|
||||
}
|
||||
|
||||
func t(num int, ch chan bool, c *etcd.Client) {
|
||||
c.SyncCluster()
|
||||
for i := 0; i < 50; i++ {
|
||||
str := fmt.Sprintf("foo_%d",num * i)
|
||||
str := fmt.Sprintf("foo_%d", num*i)
|
||||
c.Set(str, "10", 0)
|
||||
}
|
||||
ch<-true
|
||||
ch <- true
|
||||
}
|
||||
|
Reference in New Issue
Block a user