Dynamic Parameterization in JMeter CLI Execution

When running JMeter in non-GUI mode on Linux, modifying parameters typically requires editing the JMX file to locate and adjust specific variables. This can be tedious and error-prone.

Parameterization using -J and -G command-line options simplifies this process by allowing variable values to be passed directly at invocation.

The -J and -G Options

  • Syntax: -JvariableName=value or -GvariableName=value
  • Common purpose: Set JMeter properties such as thread count, loop count, ramp-up time, etc.
  • Difference: -J sets local JMeter properties; -G sets properties for remote JMeter servers. The -G option is only needed when operating with remote engines and the remote service is enabled.

Workflow for Local Parameterization

1. Edit the Test Plan in GUI Mode (Windows)

  • Add a User Defined Variables configuration element.
  • Define three variables with default values using the __P function. For example:
    • THREADS = ${__P(threadNum,1)}
    • LOOPS = ${__P(loopNum,1)}
    • RAMPUP = ${__P(rampupTime,1)}

2. Refreence the Variables in Thread Group

  • Set the thread group properties (Number of Threads, Loop Count, Ramp-Up Period) to the corresponding user-defined variables: e.g., ${THREADS}, ${LOOPS}, ${RAMPUP}.

3. Validate Locally

  • Run the test plan in GUI mode to confirm the default values are applied. Both sample requests should execute with 1 thread (since all defaults are 1).

4. Deploy and Execute on Linux

  • Upload the JMX file to the Linux machine.
  • Run JMeter with the following example command:
jmeter -n -t httptest.jmx -l log_httptest.jtl -JthreadNum=100 -JloopNum=10 -JrampupTime=10

5. Review Results

  • Transfer the generated JTL file (log_httptest.jtl) back to Windows and open it in the JMeter listener.
  • Subsequent runs require no script modification; simply change the parameter values in the command line (e.g., -JthreadNum=200) to adjust thread properties.

This approach eliminates the need to manually edit the JMX file each time runtime parameters must be altered, streamlining load testing execution in headless environments.

Tags: jmeter CLI Parameterization Performance Testing Linux

Posted on Sun, 17 May 2026 05:49:01 +0000 by rinteractive