From 44860c1c29322d0fa7ee030a54192fe5dd7aceb2 Mon Sep 17 00:00:00 2001 From: skudasov Date: Thu, 19 Dec 2024 07:07:52 +0100 Subject: [PATCH] naming --- wasp/wasp.go | 37 +++++++++++++++++-------------------- wasp/wasp_bench_test.go | 2 +- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/wasp/wasp.go b/wasp/wasp.go index b9edb1acd..fbb140ed2 100644 --- a/wasp/wasp.go +++ b/wasp/wasp.go @@ -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. @@ -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() diff --git a/wasp/wasp_bench_test.go b/wasp/wasp_bench_test.go index 897a1fe39..88b66f137 100644 --- a/wasp/wasp_bench_test.go +++ b/wasp/wasp_bench_test.go @@ -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()