Skip to content

Commit

Permalink
Fix wobbly iter/s in progressbar for varriable arrival rate
Browse files Browse the repository at this point in the history
  • Loading branch information
mstoykov committed Jan 23, 2020
1 parent 9b59904 commit cf6d82a
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions lib/executor/variable_arrival_rate.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,18 +427,18 @@ func (varr VariableArrivalRate) Run(ctx context.Context, out chan<- stats.Sample
var timer = time.NewTimer(time.Hour)
var start = time.Now()
var ch = make(chan time.Duration, 0)
var prevTime time.Duration
go varr.config.cal(ch)
for {
select {
case nextTime, ok := <-ch:
if !ok {
return nil
}
atomic.StoreInt64(tickerPeriod, int64(nextTime-prevTime))
prevTime = nextTime
b := time.Until(start.Add(nextTime))
// fmt.Println(b)
atomic.StoreInt64(tickerPeriod, int64(b))
if b < 0 {
// fmt.Println(time.Now())
err := startIteration()
if err != nil {
return err
Expand All @@ -448,7 +448,6 @@ func (varr VariableArrivalRate) Run(ctx context.Context, out chan<- stats.Sample
timer.Reset(b)
select {
case <-timer.C:
// fmt.Println(time.Now())
err := startIteration()
if err != nil {
return err
Expand Down

0 comments on commit cf6d82a

Please sign in to comment.