forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
meter.go
30 lines (24 loc) · 1.02 KB
/
meter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Copyright (C) 2019-2023, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package meter
import (
"time"
)
// Meter tracks a continuous exponential moving average of the % of time this
// meter has been running.
type Meter interface {
// Inc the meter, the read value will be monotonically increasing while
// the meter is running.
Inc(time.Time, float64)
// Dec the meter, the read value will be exponentially decreasing while the
// meter is off.
Dec(time.Time, float64)
// Read the current value of the meter, this can be used to approximate the
// percent of time the meter has been running recently. The definition of
// recently depends on the halflife of the decay function.
Read(time.Time) float64
// Returns the duration between [now] and when the value of this meter
// reaches [value], assuming that the number of cores running is always 0.
// If the value of this meter is already <= [value], returns the zero duration.
TimeUntil(now time.Time, value float64) time.Duration
}