Jmeter常见压测命令的理解 梳理

可以用 JMeter 的命令行(非GUI)模式 来执行压测,特别适合部署在服务器上或进行自动化测试。


✅ 一、命令行压测基本命令

首先要将 jmeter/bin 加入环境变量

jmeter -n -t your_test_plan.jmx -l result.jtl -e -o report_dir

参数说明:

参数含义
-n 非 GUI 模式运行
-t 指定 JMX 测试脚本路径
-l 指定保存原始结果的 JTL 文件路径
-e 生成 HTML 报告(可选)
-o 指定 HTML 报告输出目录(可选)

✅ 二、你当前适用示例

假设:

  • 测试脚本假设是:chat_completions_test.jmx

  • CSV 是:user_questions.csv(在同目录下)

  • 想将报告输出到 ./report/

Linux / Mac 命令:

jmeter -n -t chat_completions_test.jmx -l result.jtl -e -o report

Windows CMD 命令:

jmeter.bat -n -t chat_completions_test.jmx -l result.jtl -e -o report

如果 JMeter 没加到环境变量,请先进入 apache-jmeter/bin 目录再执行命令。


✅ 三、运行后的输出说明

运行时你将看到类似如下终端输出:

Creating summariser <summary>
Created the tree successfully using chat_completions_test.jmx
Starting the test @ Wed Jul 30 12:00:00 CST 2025 (1620 ms)
Waiting for possible shutdown message on port 4445
summary +   100 in 00:00:05 =   20.0/s Avg: 1200 Min: 950 Max: 1500 Err: 0 (0.00%)
Tidying up ... @ Wed Jul 30 12:00:05 CST 2025 (6200 ms)
... end of run

如果加了 -e -o report/

你会在 report/ 目录下看到一个可打开的 HTML 报告,包含:

  • 吞吐量(TPS)

  • 平均响应时间

  • 错误率

  • 各个 Sampler 的统计图

 

posted @ 2025-07-30 14:32  AlphaGeek  阅读(52)  评论(0)    收藏  举报