You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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))
The rate is an EWMA (exponentially weighted moving average) over 1 second intervals.
but I found that if the time of each round is too small, the value of rate is 0.
The rate will be 0 if you've waited less than a second as the background loop won't have computed the rate yet. It may be possible to compute some form of instantaneous rate, but it's not clear exactly what this should be.
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()
result:
11000(0/s)
--- PASS: TestP2P_MultiStreamSend (2.07s)
The text was updated successfully, but these errors were encountered: