mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
metrics: remove meter arbiter
This commit is contained in:
parent
67fa9bdda2
commit
7be876ec5d
3 changed files with 6 additions and 50 deletions
|
|
@ -28,18 +28,15 @@ func TestGetOrRegisterMeter(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMeterDecay(t *testing.T) {
|
func TestMeterDecay(t *testing.T) {
|
||||||
ma := meterArbiter{
|
|
||||||
ticker: time.NewTicker(time.Millisecond),
|
|
||||||
meters: make(map[*StandardMeter]struct{}),
|
|
||||||
}
|
|
||||||
defer ma.ticker.Stop()
|
|
||||||
m := newStandardMeter()
|
m := newStandardMeter()
|
||||||
ma.meters[m] = struct{}{}
|
|
||||||
m.Mark(1)
|
m.Mark(1)
|
||||||
ma.tickMeters()
|
|
||||||
|
// Rate is only updated after a sampling period (5s)
|
||||||
|
// elapses.
|
||||||
|
m.addToTimestamp(-5 * time.Second)
|
||||||
rateMean := m.Snapshot().RateMean()
|
rateMean := m.Snapshot().RateMean()
|
||||||
time.Sleep(100 * time.Millisecond)
|
|
||||||
ma.tickMeters()
|
m.addToTimestamp(-5 * time.Second)
|
||||||
if m.Snapshot().RateMean() >= rateMean {
|
if m.Snapshot().RateMean() >= rateMean {
|
||||||
t.Error("m.RateMean() didn't decrease")
|
t.Error("m.RateMean() didn't decrease")
|
||||||
}
|
}
|
||||||
|
|
@ -53,18 +50,6 @@ func TestMeterNonzero(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMeterStop(t *testing.T) {
|
|
||||||
l := len(arbiter.meters)
|
|
||||||
m := NewMeter()
|
|
||||||
if l+1 != len(arbiter.meters) {
|
|
||||||
t.Errorf("arbiter.meters: %d != %d\n", l+1, len(arbiter.meters))
|
|
||||||
}
|
|
||||||
m.Stop()
|
|
||||||
if l != len(arbiter.meters) {
|
|
||||||
t.Errorf("arbiter.meters: %d != %d\n", l, len(arbiter.meters))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMeterZero(t *testing.T) {
|
func TestMeterZero(t *testing.T) {
|
||||||
m := NewMeter().Snapshot()
|
m := NewMeter().Snapshot()
|
||||||
if count := m.Count(); count != 0 {
|
if count := m.Count(); count != 0 {
|
||||||
|
|
|
||||||
|
|
@ -144,23 +144,6 @@ func TestRegistryGetOrRegisterWithLazyInstantiation(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestRegistryUnregister(t *testing.T) {
|
|
||||||
l := len(arbiter.meters)
|
|
||||||
r := NewRegistry()
|
|
||||||
r.Register("foo", NewCounter())
|
|
||||||
r.Register("bar", NewMeter())
|
|
||||||
r.Register("baz", NewTimer())
|
|
||||||
if len(arbiter.meters) != l+2 {
|
|
||||||
t.Errorf("arbiter.meters: %d != %d\n", l+2, len(arbiter.meters))
|
|
||||||
}
|
|
||||||
r.Unregister("foo")
|
|
||||||
r.Unregister("bar")
|
|
||||||
r.Unregister("baz")
|
|
||||||
if len(arbiter.meters) != l {
|
|
||||||
t.Errorf("arbiter.meters: %d != %d\n", l+2, len(arbiter.meters))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestPrefixedChildRegistryGetOrRegister(t *testing.T) {
|
func TestPrefixedChildRegistryGetOrRegister(t *testing.T) {
|
||||||
r := NewRegistry()
|
r := NewRegistry()
|
||||||
pr := NewPrefixedChildRegistry(r, "prefix.")
|
pr := NewPrefixedChildRegistry(r, "prefix.")
|
||||||
|
|
|
||||||
|
|
@ -32,18 +32,6 @@ func TestTimerExtremes(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTimerStop(t *testing.T) {
|
|
||||||
l := len(arbiter.meters)
|
|
||||||
tm := NewTimer()
|
|
||||||
if l+1 != len(arbiter.meters) {
|
|
||||||
t.Errorf("arbiter.meters: %d != %d\n", l+1, len(arbiter.meters))
|
|
||||||
}
|
|
||||||
tm.Stop()
|
|
||||||
if l != len(arbiter.meters) {
|
|
||||||
t.Errorf("arbiter.meters: %d != %d\n", l, len(arbiter.meters))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestTimerFunc(t *testing.T) {
|
func TestTimerFunc(t *testing.T) {
|
||||||
var (
|
var (
|
||||||
tm = NewTimer()
|
tm = NewTimer()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue