@@ -350,26 +350,23 @@ func NewGenerator(cfg *Config) (*Generator, error) {
350350 return g , nil
351351}
352352
353- // runRPSLoop initiates the generator's RPS loop, noop if load type is VU.
353+ // runGunLoop runs the generator's Gun loop
354354// It manages request pacing for RPS after the first segment is loaded.
355- func (g * Generator ) runRPSLoop () {
356- switch g .Cfg .LoadType {
357- case RPS :
358- g .ResponsesWaitGroup .Add (1 )
359- // we run pacedCall controlled by stats.CurrentRPS
360- go func () {
361- for {
362- select {
363- case <- g .ResponsesCtx .Done ():
364- g .ResponsesWaitGroup .Done ()
365- g .Log .Info ().Msg ("RPS generator has stopped" )
366- return
367- default :
368- g .pacedCall ()
369- }
355+ func (g * Generator ) runGunLoop () {
356+ g .ResponsesWaitGroup .Add (1 )
357+ // we run pacedCall controlled by stats.CurrentRPS
358+ go func () {
359+ for {
360+ select {
361+ case <- g .ResponsesCtx .Done ():
362+ g .ResponsesWaitGroup .Done ()
363+ g .Log .Info ().Msg ("RPS generator has stopped" )
364+ return
365+ default :
366+ g .pacedCall ()
370367 }
371- }()
372- }
368+ }
369+ }()
373370}
374371
375372// runSetupWithTimeout executes the VirtualUser's setup within the configured timeout.
@@ -485,9 +482,9 @@ func (g *Generator) processSegment() bool {
485482 newRateLimit := ratelimit .New (int (g .currentSegment .From ), ratelimit .Per (g .Cfg .RateLimitUnitDuration ), ratelimit .WithoutSlack )
486483 g .rl .Store (& newRateLimit )
487484 g .stats .CurrentRPS .Store (g .currentSegment .From )
488- // start RPS loop once, in next segments we control it using g.rl ratelimiter
485+ // start Gun loop once, in next segments we control it using g.rl ratelimiter
489486 g .rpsLoopOnce .Do (func () {
490- g .runRPSLoop ()
487+ g .runGunLoop ()
491488 })
492489 case VU :
493490 oldVUs := g .stats .CurrentVUs .Load ()
0 commit comments