java 性能测试框架工具-junitperf

时间:2023-03-08 17:08:46

性能测试工具

对于 Java 开发者来说,要去学习性能测试工具未免很麻烦。

但有时候会有性能测试的需求。

junitperf

junitperf 就是一款为 Java 开发者设计的性能测试框架,如果你会 Junit,很容易就可以学会。

特性

  • 支持 Junit4+JDK1.7+,入门简单 (@since 1.0.0)

  • 支持 Junit5+JDK1.8+,使用方便 (@since 2.0.0)

  • 支持 I18N

  • 性能报告支持自定义拓展

使用例子

入门案例

入门案例地址

  • jar 包引入
<dependency>
<groupId>com.github.houbb</groupId>
<artifactId>junitperf</artifactId>
<version>2.0.0</version>
</dependency>
  • 使用例子
import com.github.houbb.junitperf.core.annotation.JunitPerfConfig;

public class HelloWorldTest {

    @JunitPerfConfig(duration = 1000)
public void helloTest() throws InterruptedException {
Thread.sleep(100);
System.out.println("Hello Junit5");
} }

测试结果

日志形式

[INFO] 2018-01-14 22:16:31.419 [] - Started at:   2018-01-14 22:16:30.194
[INFO] 2018-01-14 22:16:31.419 [] - Invocations: 10
[INFO] 2018-01-14 22:16:31.420 [] - Success: 10
[INFO] 2018-01-14 22:16:31.420 [] - Errors: 0
[INFO] 2018-01-14 22:16:31.420 [] - Thread Count: 2
[INFO] 2018-01-14 22:16:31.421 [] - Warm up: 0ms
[INFO] 2018-01-14 22:16:31.421 [] - Execution time: 1000ms
[INFO] 2018-01-14 22:16:31.421 [] - Throughput: 10/s (Required: -1/s) - PASSED
[INFO] 2018-01-14 22:16:31.424 [] - Min latency: 200.2112ms (Required: -1.0ms) - PASSED
[INFO] 2018-01-14 22:16:31.424 [] - Max latency: 205.67862ms (Required: -1.0ms) - PASSED
[INFO] 2018-01-14 22:16:31.425 [] - Ave latency: 202.97829ms (Required: -1.0ms) - PASSED

HTML 形式

java 性能测试框架工具-junitperf