2015-09-29 23:29:49 -07:00
|
|
|
# bps
|
2014-03-02 23:10:16 -08:00
|
|
|
|
2015-09-29 23:29:49 -07:00
|
|
|
`bps` is used to keep track of rates
|
2014-03-02 23:10:16 -08:00
|
|
|
|
|
|
|
It is intended to be used as such:
|
|
|
|
|
2015-09-29 23:29:49 -07:00
|
|
|
// report on 1, 10, 60 second intervals, update every second
|
|
|
|
bw, _ := NewBandwidth([]int{1, 10, 60}, time.Second)
|
|
|
|
bw.Add(10)
|
|
|
|
b := &bytes.Buffer{}
|
|
|
|
b.Write([]byte("helloooooooooooooooooooooooooooooooooooooooooooooo"))
|
|
|
|
io.Copy(bw, b)
|
2014-03-02 23:10:16 -08:00
|
|
|
time.Sleep(1 * time.Second)
|
2015-09-29 23:29:49 -07:00
|
|
|
log.Printf("%+v", bw.Cur())
|