Install
$ agentstack add skill-hellyguo-self-ai-spec-jmh-bench ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
JMH 基准测试执行指南
核心要求
- 测试默认参数:
- 预热10次
- 测试5次
- 每次预热执行100ms
- 每次测试执行20ms
- 4线程执行
- fork 3次
- 测试首推用mvnd
前置准备
1. 获取环境信息
执行 skill /java-env 获取 Java 开发环境信息:
skill java-env
确认:
- mvnd/maven 目录位置
- JDK 版本匹配项目需求
2. 配置 pom.xml
在项目中添加 JMH 依赖:
org.openjdk.jmh
jmh-core
1.37
org.openjdk.jmh
jmh-generator-annprocess
1.37
provided
org.apache.maven.plugins
maven-compiler-plugin
3.11.0
org.openjdk.jmh
jmh-generator-annprocess
1.37
执行方式
方式一:Maven Exec 插件(推荐)
# 编译项目
mvn clean compile -q
# 运行全部基准测试
mvn exec:exec -Dexec.executable="java" \
-Dexec.args="-cp %classpath org.openjdk.jmh.Main" -q
# 运行指定基准测试类
mvn exec:exec -Dexec.executable="java" \
-Dexec.args="-cp %classpath org.openjdk.jmh.Main BenchmarkClassName" -q
# 运行指定基准测试(带参数)
mvn exec:exec -Dexec.executable="java" \
-Dexec.args="-cp %classpath org.openjdk.jmh.Main BenchmarkClassName -wi 3 -i 3 -t 1 -f 1" -q
参数说明:
-wi N: Warmup 迭代次数-i N: Measurement 迭代次数-t N: 线程数-f N: Fork 次数
方式二:run_bench.sh 脚本
创建脚本 run_bench.sh:
#!/bin/bash
# Run JMH benchmark
# Usage: ./run_bench.sh [BenchmarkClass] [jmh_args...]
PROJECT_DIR=$(dirname "$0")
cd "$PROJECT_DIR"
BENCHMARK_CLASS="${1:-}"
JMH_ARGS="${2:-}"
# Build classpath
CLASSPATH="target/classes:target/test-classes:$(mvn dependency:build-classpath -Dmdep.outputFile=/dev/stdout -q)"
# Run JMH
if [ -n "$BENCHMARK_CLASS" ]; then
java -cp "$CLASSPATH" org.openjdk.jmh.Main "$BENCHMARK_CLASS" $JMH_ARGS
else
java -cp "$CLASSPATH" org.openjdk.jmh.Main
fi
使用方式:
chmod +x run_bench.sh
# 运行全部
./run_bench.sh
# 运行指定类
./run_bench.sh MyBenchmark
# 运行指定类带参数
./run_bench.sh MyBenchmark "-wi 5 -i 5"
常用命令模板
| 场景 | 命令 | |------|------| | 快速验证 | -wi 3 -i 3 -t 1 -f 1 | | 标准测试 | -wi 5 -i 5 -t 4 -f 2 | | 精确测试 | -wi 10 -i 10 -t 1 -f 3 | | 列出所有Benchmark | -l |
输出解读
典型输出示例:
Benchmark Mode Cnt Score Error Units
MyBenchmark.testMethod thrpt 5 123456.789 ± 5000 ops/s
指标说明:
thrpt: Throughput 吞吐量(ops/s)avgt: Average Time 平均耗时(us/op)sample: Sampling 时间采样Score: 平均值Error: 置信区间误差(99.9%)
最佳实践
- Warmup 充足 - 至少 5 次预热,让 JIT 编译稳定
- 避免 GC 影响 - 测试前可手动触发 GC:
System.gc() - Blackhole 消费 - 防止死代码消除:
bh.consume(result) - State 隔离 - 使用
@State(Scope.Thread)避免线程竞争 - 单线程对比 - 多框架对比时先用
-t 1消除并发因素
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: hellyguo
- Source: hellyguo/self-ai-spec
- License: Apache-2.0
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.