mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-02 23:08:07 +08:00
- Modified Godeps/Godeps.json by hand - [TEST] Updated welcome docs hash to sharness - [TEST] Updated contact doc - [TEST] disabled breaking test (t0080-repo refs local)
41 lines
651 B
Go
41 lines
651 B
Go
package peer_test
|
|
|
|
import (
|
|
"fmt"
|
|
"math/rand"
|
|
"testing"
|
|
"time"
|
|
|
|
peer "github.com/ipfs/go-ipfs/p2p/peer"
|
|
testutil "github.com/ipfs/go-ipfs/util/testutil"
|
|
)
|
|
|
|
func TestLatencyEWMAFun(t *testing.T) {
|
|
t.Skip("run it for fun")
|
|
|
|
m := peer.NewMetrics()
|
|
id, err := testutil.RandPeerID()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
mu := 100.0
|
|
sig := 10.0
|
|
next := func() time.Duration {
|
|
mu = (rand.NormFloat64() * sig) + mu
|
|
return time.Duration(mu)
|
|
}
|
|
|
|
print := func() {
|
|
fmt.Printf("%3.f %3.f --> %d\n", sig, mu, m.LatencyEWMA(id))
|
|
}
|
|
|
|
for {
|
|
select {
|
|
case <-time.After(200 * time.Millisecond):
|
|
m.RecordLatency(id, next())
|
|
print()
|
|
}
|
|
}
|
|
}
|