package gtq import ( "math/rand" "testing" "time" ) var testStat = NewStat(0) func TestStat(t *testing.T) { total := int64(10000) perOp := int64(time.Second) / total for i := int64(0); i < total; i++ { testStat.Add(1) // random sleep to introduce some flow rate variation to capture. time.Sleep(time.Duration(rand.Float64() * float64(perOp))) } t.Log("completed", testStat.Total(), "ops in", testStat.Duration(), "for a total rate of", int64(testStat.Rate()), "ops/sec", ) }