Linux 下使用 Postman 进行性能测试
一 方案总览
二 环境准备
三 执行步骤
#!/usr/bin/env bash
COLLECTION="test_collection.json"
ENV_FILE="dev.postman_environment.json"
CONCURRENT=10
TOTAL_RUNS=100
REPORT_DIR="reports"
mkdir -p "$REPORT_DIR"
for ((i=1; i<=$CONCURRENT; i++)); do
RUNS=$((TOTAL_RUNS / CONCURRENT))
[ $i -eq $CONCURRENT ] && RUNS=$((RUNS + TOTAL_RUNS % CONCURRENT)) # 余数给最后一个进程
newman run "$COLLECTION" -e "$ENV_FILE" -n "$RUNS" -r html \
--reporter-html-export "$REPORT_DIR/report_$i.html" &
done
wait
echo "All done. Reports: $REPORT_DIR/"
config:
target: "http://api.example.com"
phases:
- duration: 60
arrivalRate: 10
rampTo: 50
scenarios:
- postman:
collection: "./test_collection.json"
四 结果分析与系统监控
五 局限与建议