Help Center> CodeArts PerfTest> FAQs> Using JMeter Projects> How Do I Use the Global Variable Function?
Updated on 2023-12-19 GMT+08:00

How Do I Use the Global Variable Function?

  1. Open the JMeter script, choose Test Plan, and define variables in User Defined Variables on the right of the page.

  2. Reference variables in the script.

  3. Log in to the CodeArtsPerfTest console. In the navigation pane on the left, choose JMeter Test Projects.
  4. Click the project whose global variable is to be imported. The Test Plan List tab page is displayed.
  5. Click the task to which a global variable is to be added. The Thread Group page is displayed.
  6. Click Global Variable in the upper right corner of the page. In the dialog box that is displayed, click Add Variable.

    Variables are classified into static variables and evenly-split variables.

    • Static variable: Content is delivered as a character string. When scripts are executed in distributed mode, the variable values obtained by each node are the same. For example, if the static variable "successRate = 0.8" is delivered, 2000 tasks are concurrently executed by two actuators, and the value of successRate in the script of each actuator is 0.8.
    • Evenly-split variable: Content is delivered as an integer. When scripts are executed in distributed mode, the variable values obtained by each node are evenly distributed. Integer division is used during even distribution, and the remainder is allocated to one of the nodes. For example:
      • If tps=100 and there are four actuators, the value of the variable in the script of each actuator is 25.
      • If tps=20 and there are three actuators, the value of the variable in the script of each actuator is 8, 6, 6.
      • If tps=1 and there are four actuators, the value of the variable in the script of each actuator is 1, 0, 0, 0.

      Pay attention to the following when using the evenly-split variable:

      1. If the allocated value is sensitive to even split, manually set the number of actuators to ensure that the value of the variable is an integer multiple of the number of actuators.
      2. If the allocated value is not sensitive to even split, increase the allocated value as much as possible to reduce the impact of the integer division on the remainder and evenly split the value.
      3. If the allocated value cannot be 0, manually set the number of actuators to ensure that the value of the variable is greater than the number of actuators.

    If a variable configured in the global variable exists in Test Plan > User Defined Variables of a script, the variable value defined in the script will be overwritten.

    Otherwise, the corresponding variable will be created in Test Plan > User Defined Variables of the script.

Using JMeter Projects FAQs

more