Fixed setting unlimited rate in interactive console (#748)
* Fixed setting unlimited rate in interactive console * Add changelog entry
This commit is contained in:
parent
0e024f4208
commit
de9ac86677
@ -3,6 +3,7 @@
|
|||||||
- New
|
- New
|
||||||
- Changed
|
- Changed
|
||||||
- Fix a bug in autocalibration strategy merging, when two files have the same strategy key
|
- Fix a bug in autocalibration strategy merging, when two files have the same strategy key
|
||||||
|
- Fix panic when setting rate to 0 in the interactive console
|
||||||
|
|
||||||
- v2.1.0
|
- v2.1.0
|
||||||
- New
|
- New
|
||||||
|
|||||||
@ -19,15 +19,13 @@ func NewRateThrottle(conf *Config) *RateThrottle {
|
|||||||
Config: conf,
|
Config: conf,
|
||||||
lastAdjustment: time.Now(),
|
lastAdjustment: time.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
if conf.Rate > 0 {
|
if conf.Rate > 0 {
|
||||||
r.rateCounter = ring.New(int(conf.Rate * 5))
|
r.rateCounter = ring.New(int(conf.Rate * 5))
|
||||||
} else {
|
|
||||||
r.rateCounter = ring.New(conf.Threads * 5)
|
|
||||||
}
|
|
||||||
if conf.Rate > 0 {
|
|
||||||
ratemicros := 1000000 / conf.Rate
|
ratemicros := 1000000 / conf.Rate
|
||||||
r.RateLimiter = time.NewTicker(time.Microsecond * time.Duration(ratemicros))
|
r.RateLimiter = time.NewTicker(time.Microsecond * time.Duration(ratemicros))
|
||||||
} else {
|
} else {
|
||||||
|
r.rateCounter = ring.New(conf.Threads * 5)
|
||||||
//Million rps is probably a decent hardcoded upper speedlimit
|
//Million rps is probably a decent hardcoded upper speedlimit
|
||||||
r.RateLimiter = time.NewTicker(time.Microsecond * 1)
|
r.RateLimiter = time.NewTicker(time.Microsecond * 1)
|
||||||
}
|
}
|
||||||
@ -72,10 +70,17 @@ func (r *RateThrottle) ChangeRate(rate int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
r.RateLimiter.Stop()
|
r.RateLimiter.Stop()
|
||||||
|
if rate > 0 {
|
||||||
r.RateLimiter = time.NewTicker(time.Microsecond * time.Duration(ratemicros))
|
r.RateLimiter = time.NewTicker(time.Microsecond * time.Duration(ratemicros))
|
||||||
r.Config.Rate = int64(rate)
|
|
||||||
// reset the rate counter
|
// reset the rate counter
|
||||||
r.rateCounter = ring.New(rate * 5)
|
r.rateCounter = ring.New(rate * 5)
|
||||||
|
} else {
|
||||||
|
r.RateLimiter = time.NewTicker(time.Microsecond * 1)
|
||||||
|
// reset the rate counter
|
||||||
|
r.rateCounter = ring.New(r.Config.Threads * 5)
|
||||||
|
}
|
||||||
|
|
||||||
|
r.Config.Rate = int64(rate)
|
||||||
}
|
}
|
||||||
|
|
||||||
// rateTick adds a new duration measurement tick to rate counter
|
// rateTick adds a new duration measurement tick to rate counter
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user