laitimes

A detailed guide to using the Apache JMeter scheduler

author:Tester: Mueller
A detailed guide to using the Apache JMeter scheduler

Preface

Apache JMeter is an open-source tool for performance testing, which is widely used to simulate load testing in various scenarios. The Scheduler is an important feature of JMeter that helps testers execute test plans within a specified period of time. This guide will go into more detail about how to configure and use JMeter's scheduler.

Start JMeter

Navigate to JMeter's bin directory in the command line and run the following command to launch the JMeter GUI:

bashjmeter
           

Create a test plan

  1. To add a thread group:

打开 JMeter 后,在测试计划(Test Plan)中右键点击,选择 Add -> Threads (Users) -> Thread Group。

  1. Configure thread groups
  • 线程数量(Number of Threads):设定并发用户数。
  • Ramp-Up Period: Set the time interval for all users to start.
  • 循环次数(Loop Count):设定每个用户的循环次数。

Configure the scheduler

  1. Enable the scheduler:

Select the thread group and tick the Scheduler checkbox at the bottom of the panel.

  1. Set the scheduling time:
  • Start Time: Set the time when the test will start.
  • End Time: Set the time when the test will end.
  • Duration: Set the duration of the test in seconds.
  • Startup Delay: Set the delay time (seconds) before the test starts.

The scheduler can be set up through the GUI interface or by modifying the relevant properties in the jmx file. Here's an example configuration:

yaml<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group" enabled="true">
  <stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
  <elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller" enabled="true">
    <boolProp name="LoopController.continue_forever">false</boolProp>
    <stringProp name="LoopController.loops">1</stringProp>
  </elementProp>
  <stringProp name="ThreadGroup.num_threads">10</stringProp>
  <stringProp name="ThreadGroup.ramp_time">1</stringProp>
  <longProp name="ThreadGroup.start_time">1714567200000</longProp>
  <longProp name="ThreadGroup.end_time">1714570800000</longProp>
  <boolProp name="ThreadGroup.scheduler">true</boolProp>
  <stringProp name="ThreadGroup.duration">3600</stringProp>
  <stringProp name="ThreadGroup.delay">0</stringProp>
</ThreadGroup>
           

Add samplers and listeners

  1. Add an HTTP sampler:
  • 在线程组上右键点击,选择 Add -> Sampler -> HTTP Request。
  • Configure the URL, method (GET/POST), and request parameters for the request.
  1. To add a listener:
  • 在线程组或测试计划上右键点击,选择 Add -> Listener,添加如 View Results Tree、Summary Report 等监听器,用于查看测试结果。

Perform the test

  1. To save a test plan:

Select File -> Save As in the menu bar to save your test plan file (.jmx).

  1. Startup Test:

Click the green start button on the toolbar to start the test plan.

Analysis of results

  1. See the results:

测试完成后,在 View Results Tree 或 Summary Report 中查看测试结果。

  1. Analyze performance data:

Analyze the performance of the system through the response time, throughput, error rate and other indicators in the results.

summary

JMeter's scheduler feature helps test engineers automate performance tests within a specific amount of time, enabling more precise test control. This guide shows you how to install JMeter, create a test plan, configure the scheduler, and analyze the test results.