Documentation ¶
Overview ¶
Package bps keeps track of byte rates
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BPS ¶
BPS calculates bandwidth rates.
Instantiate a BPS using one of the New* functions then feed bytes either via BPS.Add, or writing to it (it implements io.Writer). When the accumulated values are needed call BPS.Rate. When the BPS is no loner needed call BPS.Close
func New ¶
New Returns a populated and ready to use BPS.
bytes per second are reported for the last time interval (defined by interval), and is updated every (interval / 100) seconds.
func NewPrecise ¶
NewPrecise behaves like New, but allows the user to specify the temporal resolution.
If you need to query more or less frequently than interval / 100 you'll want to use this function.
type Multi ¶
type Multi struct {
// contains filtered or unexported fields
}
Multi wraps multiple BPS
Example ¶
// Create a Multi that records information for 1s, 10s, and 1m bw, err := NewMulti(1*time.Second, 10*time.Second, 1*time.Minute) if err != nil { log.Fatal(err) } // Add some data, then print out rates;w bw.Add(1) fmt.Printf("%v\n", len(bw.Rate()))
Output: 3