add error package

This commit is contained in:
Xiang Li
2013-08-17 20:41:15 -07:00
parent 8ed67bedbb
commit cf2d6888c2
10 changed files with 95 additions and 128 deletions

View File

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

View File

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