使用contiperf进行压测

ContiPerf是一款轻量级的性能测试工具,可通过指定并发线程数及执行时间来进行压力测试,也可设置调用次数。该工具支持生成测试报告,报告中包含关键指标Throughput(QPS)和AverageLatency(平均响应时间)。

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,表示平均响应速度。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值