contiperf是一个轻量级的压测工具,使用非常的广泛,并且可以生成report,帮助做性能分析。
简单例子
public class TestContiPerf {
@Rule
public ContiPerfRule i = new ContiPerfRule();
@Test
@PerfTest(threads = 100,duration=15000)
public void test() throws Exception {
}
}
可以通过PerfTest制定并发线程数和执行时间,如threads=100,duration=15000。这里15000表示15秒。
public class TestContiPerf {
@Rule
public ContiPerfRule i = new ContiPerfRule();
@Test
@PerfTest(threads = 100,invocations=100)
public void test() throws Exception {
}
}
也可以通过invocations指定调用的次数。
至于更加具体的说明,可以参看http://databene.org/contiperf
pom文件
<dependency>
<groupId>org.databene</groupId>
<artifactId>contiperf</artifactId>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
contiperf自带的测试报告
可以在工程的target/contiperf-report目录下找到一个index.htm文件,内容如下:
里面最重要的有两个参数,一个是Throughput,表示QPS,另一个是Average Latency,表示平均响应速度。
ContiPerf是一款轻量级的性能测试工具,可通过指定并发线程数及执行时间来进行压力测试,也可设置调用次数。该工具支持生成测试报告,报告中包含关键指标Throughput(QPS)和AverageLatency(平均响应时间)。
164

被折叠的 条评论
为什么被折叠?



