added example
This commit is contained in:
parent
323daff95b
commit
3398b4f131
21
example_multi_test.go
Normal file
21
example_multi_test.go
Normal 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
|
||||
}
|
Loading…
Reference in New Issue
Block a user