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-30 23:12:14 -07:00
|
|
|
// report on the rate over a 60 second interval, update every second
|
|
|
|
bw, _ := New(60*time.Second, 60)
|
2015-09-29 23:29:49 -07:00
|
|
|
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-30 23:12:14 -07:00
|
|
|
log.Printf("%+v", bw.HumanRate())
|