func NewThrottle(r float64, dt time.Duration) *Throttle {
	var f float64
	switch {
	case r <= 0:
		f = -1  
	case r >= 1:
		f = 0  
	default:
		f = (1 - r) / r
	}
	if dt < 0 {
		dt = 0
	}
	return &Throttle{f: f, dt: dt, tt: time.Now().Add(dt)}
}
NewThrottle creates a new Throttle with a throttle value r and
a minimum allocated run time slice of dt:

r == 0: "empty" throttle; the goroutine is always sleeping
r == 1: full throttle; the goroutine is never sleeping

A value of r == 0.6 throttles a goroutine such that it runs
approx. 60% of the time, and sleeps approx. 40% of the time.
Values of r < 0 or r > 1 are clamped down to values between 0 and 1.
Values of dt < 0 are set to 0.
package util
import "time"
type Throttle struct {
	f  float64        
	dt time.Duration  
	tr time.Duration  
	ts time.Duration  
	tt time.Time      
}