-
-
Notifications
You must be signed in to change notification settings - Fork 515
/
main.go
42 lines (32 loc) · 892 Bytes
/
main.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
package main
import (
"time"
console "github.com/AsynkronIT/goconsole"
"github.com/AsynkronIT/protoactor-go/actor"
"github.com/AsynkronIT/protoactor-go/examples/remotelatency/messages"
"github.com/AsynkronIT/protoactor-go/remote"
"runtime"
)
// import "runtime/pprof"
func makeTimestamp() int64 {
return time.Now().UnixNano() / int64(time.Millisecond)
}
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
messageCount := 1000000
remote.Start("127.0.0.1:8081", remote.WithEndpointWriterBatchSize(10000))
rootContext := actor.EmptyRootContext
remote := actor.NewPID("127.0.0.1:8080", "remote")
rootContext.RequestFuture(remote, &messages.Start{}, 5*time.Second).
Wait()
for i := 0; i < messageCount; i++ {
message := &messages.Ping{
Time: makeTimestamp(),
}
rootContext.Send(remote, message)
if i%1000 == 0 {
time.Sleep(500)
}
}
console.ReadLine()
}