mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
metrics: remove inactiveMeter, timer Stop()
This commit is contained in:
parent
8a99570807
commit
25d2746dbe
2 changed files with 1 additions and 15 deletions
|
|
@ -50,7 +50,7 @@ func ExampleMetrics() metrics.Registry {
|
||||||
//metrics.NewRegisteredHistogram("test/histogram", registry, metrics.NewSampleSnapshot(3, []int64{1, 2, 3}))
|
//metrics.NewRegisteredHistogram("test/histogram", registry, metrics.NewSampleSnapshot(3, []int64{1, 2, 3}))
|
||||||
metrics.NewRegisteredHistogram("test/histogram", registry, s)
|
metrics.NewRegisteredHistogram("test/histogram", registry, s)
|
||||||
}
|
}
|
||||||
registry.Register("test/meter", metrics.NewInactiveMeter())
|
registry.Register("test/meter", metrics.NewMeter())
|
||||||
{
|
{
|
||||||
timer := metrics.NewRegisteredResettingTimer("test/resetting_timer", registry)
|
timer := metrics.NewRegisteredResettingTimer("test/resetting_timer", registry)
|
||||||
timer.Update(10 * time.Millisecond)
|
timer.Update(10 * time.Millisecond)
|
||||||
|
|
@ -68,7 +68,6 @@ func ExampleMetrics() metrics.Registry {
|
||||||
timer.Update(120 * time.Millisecond)
|
timer.Update(120 * time.Millisecond)
|
||||||
timer.Update(23 * time.Millisecond)
|
timer.Update(23 * time.Millisecond)
|
||||||
timer.Update(24 * time.Millisecond)
|
timer.Update(24 * time.Millisecond)
|
||||||
timer.Stop()
|
|
||||||
}
|
}
|
||||||
registry.Register("test/empty_resetting_timer", metrics.NewResettingTimer().Snapshot())
|
registry.Register("test/empty_resetting_timer", metrics.NewResettingTimer().Snapshot())
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,6 @@ type TimerSnapshot interface {
|
||||||
// Timer capture the duration and rate of events.
|
// Timer capture the duration and rate of events.
|
||||||
type Timer interface {
|
type Timer interface {
|
||||||
Snapshot() TimerSnapshot
|
Snapshot() TimerSnapshot
|
||||||
Stop()
|
|
||||||
Time(func())
|
Time(func())
|
||||||
UpdateSince(time.Time)
|
UpdateSince(time.Time)
|
||||||
Update(time.Duration)
|
Update(time.Duration)
|
||||||
|
|
@ -21,8 +20,6 @@ type Timer interface {
|
||||||
|
|
||||||
// GetOrRegisterTimer returns an existing Timer or constructs and registers a
|
// GetOrRegisterTimer returns an existing Timer or constructs and registers a
|
||||||
// new StandardTimer.
|
// new StandardTimer.
|
||||||
// Be sure to unregister the meter from the registry once it is of no use to
|
|
||||||
// allow for garbage collection.
|
|
||||||
func GetOrRegisterTimer(name string, r Registry) Timer {
|
func GetOrRegisterTimer(name string, r Registry) Timer {
|
||||||
if nil == r {
|
if nil == r {
|
||||||
r = DefaultRegistry
|
r = DefaultRegistry
|
||||||
|
|
@ -31,7 +28,6 @@ func GetOrRegisterTimer(name string, r Registry) Timer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCustomTimer constructs a new StandardTimer from a Histogram and a Meter.
|
// NewCustomTimer constructs a new StandardTimer from a Histogram and a Meter.
|
||||||
// Be sure to call Stop() once the timer is of no use to allow for garbage collection.
|
|
||||||
func NewCustomTimer(h Histogram, m Meter) Timer {
|
func NewCustomTimer(h Histogram, m Meter) Timer {
|
||||||
if !Enabled {
|
if !Enabled {
|
||||||
return NilTimer{}
|
return NilTimer{}
|
||||||
|
|
@ -43,8 +39,6 @@ func NewCustomTimer(h Histogram, m Meter) Timer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRegisteredTimer constructs and registers a new StandardTimer.
|
// NewRegisteredTimer constructs and registers a new StandardTimer.
|
||||||
// Be sure to unregister the meter from the registry once it is of no use to
|
|
||||||
// allow for garbage collection.
|
|
||||||
func NewRegisteredTimer(name string, r Registry) Timer {
|
func NewRegisteredTimer(name string, r Registry) Timer {
|
||||||
c := NewTimer()
|
c := NewTimer()
|
||||||
if nil == r {
|
if nil == r {
|
||||||
|
|
@ -56,7 +50,6 @@ func NewRegisteredTimer(name string, r Registry) Timer {
|
||||||
|
|
||||||
// NewTimer constructs a new StandardTimer using an exponentially-decaying
|
// NewTimer constructs a new StandardTimer using an exponentially-decaying
|
||||||
// sample with the same reservoir size and alpha as UNIX load averages.
|
// sample with the same reservoir size and alpha as UNIX load averages.
|
||||||
// Be sure to call Stop() once the timer is of no use to allow for garbage collection.
|
|
||||||
func NewTimer() Timer {
|
func NewTimer() Timer {
|
||||||
if !Enabled {
|
if !Enabled {
|
||||||
return NilTimer{}
|
return NilTimer{}
|
||||||
|
|
@ -71,7 +64,6 @@ func NewTimer() Timer {
|
||||||
type NilTimer struct{}
|
type NilTimer struct{}
|
||||||
|
|
||||||
func (NilTimer) Snapshot() TimerSnapshot { return (*emptySnapshot)(nil) }
|
func (NilTimer) Snapshot() TimerSnapshot { return (*emptySnapshot)(nil) }
|
||||||
func (NilTimer) Stop() {}
|
|
||||||
func (NilTimer) Time(f func()) { f() }
|
func (NilTimer) Time(f func()) { f() }
|
||||||
func (NilTimer) Update(time.Duration) {}
|
func (NilTimer) Update(time.Duration) {}
|
||||||
func (NilTimer) UpdateSince(time.Time) {}
|
func (NilTimer) UpdateSince(time.Time) {}
|
||||||
|
|
@ -94,11 +86,6 @@ func (t *StandardTimer) Snapshot() TimerSnapshot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop stops the meter.
|
|
||||||
func (t *StandardTimer) Stop() {
|
|
||||||
t.meter.Stop()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Time record the duration of the execution of the given function.
|
// Time record the duration of the execution of the given function.
|
||||||
func (t *StandardTimer) Time(f func()) {
|
func (t *StandardTimer) Time(f func()) {
|
||||||
ts := time.Now()
|
ts := time.Now()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue