You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于公式计算JMeter步进线程组执行时长的技术问题

Calculate Execution Duration for Stepping Thread Group (Mathematical Formula)

I've translated your Java code logic into a set of mathematical formulas so you can compute the total execution duration of a Stepping Thread Group directly, without relying on code loops. Let's break this down step by step:

First, let's define all the input parameters (matching your code variables):

  • TotalThreads: Total number of threads to run
  • firstWait: Initial wait time before starting any threads (seconds)
  • thenStart_threads: Number of threads launched in the first batch
  • nextAdd_threads: Number of threads added in each subsequent batch
  • threadsEverySeconds: Interval between starting subsequent thread batches (seconds)
  • usingRamupSeconds: Ramp-up time to launch a batch of threads (seconds)
  • holdForSeconds: Duration to run all threads at full capacity (seconds)
  • finallyStopThreads: Number of threads stopped in each batch during ramp-down
  • down_threadsEverySeconds: Interval between stopping subsequent thread batches (seconds)

1. Ramp-Up Phase Duration

This covers the time from initial wait to launching all threads. We split this into two scenarios based on whether you have an initial thread batch:

Scenario 1: thenStart_threads > 0

  1. Initial batch setup: Time to wait, launch the first batch, and wait for the next interval:
    initial_ramp = firstWait + usingRamupSeconds + threadsEverySeconds
    
  2. Remaining threads to launch:
    RemainingThreads = TotalThreads - thenStart_threads
    
  3. Calculate full batches and final partial batch:
    • Number of complete batches of nextAdd_threads threads:
      full_batches = floor( (RemainingThreads - 1) / nextAdd_threads )
      
      (We subtract 1 to ensure the final full batch doesn't include an extra interval)
    • Threads in the final (possibly partial) batch:
      final_batch_threads = RemainingThreads - (full_batches * nextAdd_threads)
      
  4. Time for remaining batches:
    • Time for all full batches (each includes ramp-up + interval):
      full_batches_time = full_batches * (usingRamupSeconds + threadsEverySeconds)
      
    • Time for the final batch:
      final_batch_time = if final_batch_threads == nextAdd_threads 
                         then usingRamupSeconds 
                         else (final_batch_threads / nextAdd_threads) * usingRamupSeconds
      
  5. Total ramp-up time:
    rampupTime = initial_ramp + full_batches_time + final_batch_time
    

Scenario 2: thenStart_threads = 0

Skip the initial batch setup, start with the initial wait time, then calculate remaining batches the same way:

rampupTime = firstWait + full_batches_time + final_batch_time

(Use the same RemainingThreads = TotalThreads, full_batches, and final_batch_time calculations as above)


2. Ramp-Down Phase Duration

This covers the time to stop all threads after the hold phase. The logic is: we stop finallyStopThreads threads each interval, and don't need an interval after the final stop:

RampDown = ( (TotalThreads // finallyStopThreads) - 1 ) * down_threadsEverySeconds

(The // denotes integer division, matching your Java code's behavior)


3. Total Execution Duration

Add up all three phases to get the total runtime:

TotalDuration = rampupTime + holdForSeconds + RampDown

Example Validation (Using Your Code's Parameters)

Let's test with your sample values:

TotalThreads=500, firstWait=25, thenStart_threads=5, nextAdd_threads=25, threadsEverySeconds=30, usingRamupSeconds=5, holdForSeconds=600, finallyStopThreads=25, down_threadsEverySeconds=25
  1. RemainingThreads = 500 - 5 = 495
  2. full_batches = floor( (495-1)/25 ) = 19
  3. final_batch_threads = 495 - (19*25) = 20
  4. final_batch_time = (20/25)*5 = 4
  5. initial_ramp = 25 +5 +30 = 60
  6. full_batches_time =19*(5+30)= 665
  7. rampupTime=60+665+4=729
  8. RampDown=(500//25 -1)*25= (20-1)*25=475
  9. TotalDuration=729+600+475=1804

This matches the output from your Java code perfectly, confirming the formulas work.

内容的提问来源于stack exchange,提问作者Raju

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 06:45:10