惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
Webroot Blog
Webroot Blog
T
The Blog of Author Tim Ferriss
S
Schneier on Security
罗磊的独立博客
P
Privacy & Cybersecurity Law Blog
阮一峰的网络日志
阮一峰的网络日志
F
Fortinet All Blogs
P
Palo Alto Networks Blog
月光博客
月光博客
MongoDB | Blog
MongoDB | Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Simon Willison's Weblog
Simon Willison's Weblog
量子位
NISL@THU
NISL@THU
C
CERT Recently Published Vulnerability Notes
Cisco Talos Blog
Cisco Talos Blog
Stack Overflow Blog
Stack Overflow Blog
Recorded Future
Recorded Future
K
Kaspersky official blog
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
L
Lohrmann on Cybersecurity
酷 壳 – CoolShell
酷 壳 – CoolShell
GbyAI
GbyAI
L
LINUX DO - 热门话题
Help Net Security
Help Net Security
B
Blog RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
I
InfoQ
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
The Cloudflare Blog
H
Heimdal Security Blog
Last Week in AI
Last Week in AI
美团技术团队
云风的 BLOG
云风的 BLOG
C
Check Point Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
V
Visual Studio Blog
G
GRAHAM CLULEY
AI
AI
Security Latest
Security Latest
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
雷峰网
雷峰网
Cyberwarzone
Cyberwarzone
Microsoft Security Blog
Microsoft Security Blog
P
Proofpoint News Feed

博客园 - 大卫小东(Sheldon)

Rust 推荐使用宏而非普通函数的场景 华为公司发布半导体演进新范式 - “韬(τ)定律”(Tau Law) 霍尔定理和最大流算法 入门 Rudist v0.5.1 发布:AI 驱动的 Redis 客户端,更快、更直观 Rudist 0.4.3 发布:让 AI Agent 替你操作 Redis 集成AI 的 Redis 客户端 Rudist发布新版了 大模型智能体 (agent)简易流程介绍 在Mac安装阿里巴巴新神器copaw GIM 2.0 发布:真正让 AI 提交消息可定制、可控、可项目级优化 postgreSQL 中的自定义操作符 SQL查询中的窗口函数(主要以 PostgreSQL 为例) SQL中的CTE用法初步(Common Table Expression公共表表达式) 公司新来的00后老板让我们把数据库改成PostgreSQL,大家怒了😂 革命你的 Git 提交消息 - GIM 1.8.0 发布了! 如何用Java25编译Java17的项目 写了一个BBP算法的实现库,欢迎讨论 智能生成git提交消息工具 GIM 发布 1.7 版本了 面向 Git 用户的 jujutsu 使用入门 GIM 1.5发布了! 支持Windows系统了 GIM 1.4 发布了 (附使用 mkdocs 快速制作静态站点流程)
使用JMH对远程接口进行压测
大卫小东(Sheldon) · 2025-10-31 · via 博客园 - 大卫小东(Sheldon)

在 《java中的基准测试框架JMH》中我们使用JMH框架进行Java SDK中的API的压测。
最近我又遇到了需要对第三方接口进行压测的需求,又用到了它。

也可以用Gatling https://www.cnblogs.com/somefuture/p/18624127

JHM(Java Microbenchmark Harness)是OpenJDK团队开发的Java微基准测试框架,专门用于精确测量Java代码的性能,精度可以达到纳秒级别。

提供吞吐量、平均时间、采样时间等多种测试模式
自动进行预热处理,使JVM达到稳定状态
支持多线程测试,模拟真实并发场景

虽然它本身是针对JDK的,但是配合http框架也可以对远程API进行压测。

项目我放到网上了: https://github.com/davelet/local-load-test

用法是:

java -Dapi.baseUrl=http://localhost:8080 \
  -Dapi.endpoint=/api/v1/test \
  -Dapi.method=GET \
  -jar target/benchmarks.jar \
  -t 10 -wi 3 -w 5s -i 5 -r 10s \
  ApiLoadTestBenchmark

API配置参数(通过-D指定)

参数 说明 默认值
api.baseUrl API基础URL http://localhost:8080
api.endpoint API端点路径 /api/v1/test
api.method HTTP方法 GET
api.body 请求体(JSON) ""
api.headers HTTP Headers ""
api.connectionTimeout 连接超时(ms) 5000
api.socketTimeout 响应超时(ms) 10000

JMH性能测试参数(通过命令行选项指定)

参数 说明 默认值 示例
-t 并发线程数 1 -t 10
-wi 预热迭代次数 0 -wi 3
-w 每次预热时长 10s -w 5s
-i 测试迭代次数 1 -i 5
-r 每次测试时长 10s -r 10s
-f JVM fork次数 1 -f 1

更复杂和详细的说明可以参考 https://github.com/davelet/local-load-test/blob/develop/README.md