From 3398b4f131b13547a5e73d16f829b3c1f04b3cfc Mon Sep 17 00:00:00 2001 From: "Stephen McQuay (smcquay)" Date: Thu, 22 Sep 2016 23:03:32 -0700 Subject: [PATCH] added example --- example_multi_test.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 example_multi_test.go diff --git a/example_multi_test.go b/example_multi_test.go new file mode 100644 index 0000000..9aa4a88 --- /dev/null +++ b/example_multi_test.go @@ -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 +}