You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I copied the example code into a file, build with Go 1.1.0.3 and execute. The results are that it returns all zeros. (after I fixed some missing closing brackets in the example code)
$ go build average-example.go
$ go version
go version go1.10.3 windows/amd64
$ ./average-example.exe
Average of last 1m: 0.000000
Average of last 5m: 0.000000
Average of last 15m: 0.000000
Counter has a total of 0 over 0 samples
$
average_example.go:
package main
import (
"fmt"
"time"
"github.com/prep/average"
)
func main() {
// Create a SlidingWindow that has a window of 15 minutes, with a
// granulity of 1 minute.
sw := average.MustNew(15*time.Minute, time.Minute)
defer sw.Stop()
// Do some work.
sw.Add(15)
// Do some more work.
sw.Add(22)
// Do even more work.
sw.Add(22)
fmt.Printf("Average of last 1m: %f\n", sw.Average(time.Minute))
fmt.Printf("Average of last 5m: %f\n", sw.Average(5*time.Minute))
fmt.Printf("Average of last 15m: %f\n\n", sw.Average(15*time.Minute))
total, numSamples := sw.Total(15 * time.Minute)
fmt.Printf("Counter has a total of %d over %d samples", total, numSamples)
}
The text was updated successfully, but these errors were encountered:
I copied the example code into a file, build with Go 1.1.0.3 and execute. The results are that it returns all zeros. (after I fixed some missing closing brackets in the example code)
The text was updated successfully, but these errors were encountered: