Skip to content

Commit

Permalink
Support rate less than 1 item per second
Browse files Browse the repository at this point in the history
  • Loading branch information
dave committed Mar 1, 2018
1 parent 3d81f81 commit f3afebf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion blaster/loop-ticker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ func (b *Blaster) startTickerLoop(ctx context.Context) {
ticker = &time.Ticker{} // empty *time.Ticker will have nil C, so block forever.
return
}
ticker = time.NewTicker(time.Second / time.Duration(b.Rate/float64(len(b.PayloadVariants))))
ticksPerSecond := b.Rate/float64(len(b.PayloadVariants))
ticksPerMs := ticksPerSecond / 1000.0
ticksPerUs := ticksPerMs / 1000.0
ticksPerNs := ticksPerUs / 1000.0
nsPerTick := 1.0 / ticksPerNs

ticker = time.NewTicker(time.Nanosecond * time.Duration(nsPerTick))
}

changeRate := func(rate float64) {
Expand Down

0 comments on commit f3afebf

Please sign in to comment.