-
Notifications
You must be signed in to change notification settings - Fork 12
Open
Description
I deduced from the meterexample that the value of rate is the cumulative value of the mark/total time, but I found that if the time of each round is too small, the value of rate is 0.
Below is my code and result:
mt:=meter.NewMeter()
testStreamNum := 1000
var wg sync.WaitGroup
send := func(wg *sync.WaitGroup) {
defer wg.Done()
resp, err := p1.Send(p2.PeerID(), msg)
assert.Nil(t, err)
assert.EqualValues(t, ack,resp)
}
for i := 0; i < testStreamNum; i++ {
wg.Add(1)
go send(&wg)
mt.Mark(uint64(len(msg))) //uint64(len(msg)=11
}
rate:=mt.Snapshot().Rate
wg.Wait()
time.Sleep(2*time.Second)
total:=mt.Snapshot().Total
fmt.Printf("%d(%d/s)\n",total,roundTens(rate))
result:
11000(0/s)
--- PASS: TestP2P_MultiStreamSend (2.07s)
Metadata
Metadata
Assignees
Labels
No labels