-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
49 lines (38 loc) · 801 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"./godis"
"errors"
"log"
"sync"
"sync/atomic"
"syscall"
)
var ops int64= 0
func Afunction(client *godis.Client, wg sync.WaitGroup) {
var ts, te syscall.Timeval
syscall.Gettimeofday(&ts)
start:=(int64(ts.Sec)*1e3 + int64(ts.Usec)/1e3)
h := func(v godis.RespInfo) (interface{}, error){
defer wg.Add(-1)
syscall.Gettimeofday(&te)
end:=(int64(te.Sec)*1e3 + int64(te.Usec)/1e3)
cost:=end-start
atomic.AddInt64(&ops, cost)
log.Println("cost: %d",ops)
return nil, errors.New("Ssss")
}
n := make(godis.ProtoType)
n["a"]=1
n["b"]=2
client.Call("hello",&h,n)
}
func main (){
client, _:=godis.NewClient("3", "127.0.0.1:6379",5)
var wg sync.WaitGroup
l:=10000
for i := 0; i < l; i++ {
wg.Add(1)
go Afunction(client,wg)
}
wg.Wait()
}