Skip to content

Commit

Permalink
naming
Browse files Browse the repository at this point in the history
  • Loading branch information
skudasov committed Dec 19, 2024
1 parent 26b8602 commit 44860c1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
37 changes: 17 additions & 20 deletions wasp/wasp.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,26 +350,23 @@ func NewGenerator(cfg *Config) (*Generator, error) {
return g, nil
}

// runRPSLoop initiates the generator's RPS loop, noop if load type is VU.
// runGunLoop runs the generator's Gun loop
// It manages request pacing for RPS after the first segment is loaded.
func (g *Generator) runRPSLoop() {
switch g.Cfg.LoadType {
case RPS:
g.ResponsesWaitGroup.Add(1)
// we run pacedCall controlled by stats.CurrentRPS
go func() {
for {
select {
case <-g.ResponsesCtx.Done():
g.ResponsesWaitGroup.Done()
g.Log.Info().Msg("RPS generator has stopped")
return
default:
g.pacedCall()
}
func (g *Generator) runGunLoop() {
g.ResponsesWaitGroup.Add(1)
// we run pacedCall controlled by stats.CurrentRPS
go func() {
for {
select {
case <-g.ResponsesCtx.Done():
g.ResponsesWaitGroup.Done()
g.Log.Info().Msg("RPS generator has stopped")
return
default:
g.pacedCall()
}
}()
}
}
}()
}

// runSetupWithTimeout executes the VirtualUser's setup within the configured timeout.
Expand Down Expand Up @@ -485,9 +482,9 @@ func (g *Generator) processSegment() bool {
newRateLimit := ratelimit.New(int(g.currentSegment.From), ratelimit.Per(g.Cfg.RateLimitUnitDuration), ratelimit.WithoutSlack)
g.rl.Store(&newRateLimit)
g.stats.CurrentRPS.Store(g.currentSegment.From)
// start RPS loop once, in next segments we control it using g.rl ratelimiter
// start Gun loop once, in next segments we control it using g.rl ratelimiter
g.rpsLoopOnce.Do(func() {
g.runRPSLoop()
g.runGunLoop()
})
case VU:
oldVUs := g.stats.CurrentVUs.Load()
Expand Down
2 changes: 1 addition & 1 deletion wasp/wasp_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func BenchmarkPacedCall(b *testing.B) {
Gun: NewMockGun(&MockGunConfig{}),
})
require.NoError(b, err)
gen.runRPSLoop()
gen.runGunLoop()
b.ResetTimer()
for i := 0; i < b.N; i++ {
gen.pacedCall()
Expand Down

0 comments on commit 44860c1

Please sign in to comment.