added example

This commit is contained in:
Stephen McQuay 2016-09-22 23:03:32 -07:00
parent 323daff95b
commit 3398b4f131
No known key found for this signature in database
GPG Key ID: 1ABF428F71BAFC3D

21
example_multi_test.go Normal file
View File

@ -0,0 +1,21 @@
package bps
import (
"fmt"
"log"
"time"
)
func ExampleMulti() {
// 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
}