51Testing软件测试论坛

标题: 带走走进junitperf性能测试框架工具中 [打印本页]

作者: lsekfe    时间: 2022-10-19 13:19
标题: 带走走进junitperf性能测试框架工具中
 性能测试工具
  对于 Java 开发者来说,要去学习性能测试工具未免很麻烦。
  但有时候会有性能测试的需求。
junitperf
  junitperf 就是一款为 Java 开发者设计的性能测试框架,如果你会 Junit,很容易就可以学会。
  特性
  ·支持 Junit4+JDK1.7+,入门简单 (@since 1.0.0)
  · 支持 Junit5+JDK1.8+,使用方便 (@since 2.0.0)
  · 支持 I18N
  · 性能报告支持自定义拓展
  使用例子
  入门案例
  · jar 包引入
  1. <font size="3"> <dependency>

  2.       <groupId>com.github.houbb</groupId>

  3.       <artifactId>junitperf</artifactId>

  4.       <version>2.0.0</version>

  5.   </dependency></font>
复制代码
· 使用例子
  1. <font size="3">import com.github.houbb.junitperf.core.annotation.JunitPerfConfig;

  2.   public class HelloWorldTest {

  3.       @JunitPerfConfig(duration = 1000)

  4.       public void helloTest() throws InterruptedException {

  5.           Thread.sleep(100);

  6.           System.out.println("Hello Junit5");

  7.       }

  8.   }</font>
复制代码
测试结果
  日志形式

  1. <font size="3"> [INFO] 2018-01-14 22:16:31.419 [] - Started at:   2018-01-14 22:16:30.194

  2.   [INFO] 2018-01-14 22:16:31.419 [] - Invocations:  10

  3.   [INFO] 2018-01-14 22:16:31.420 [] - Success:  10

  4.   [INFO] 2018-01-14 22:16:31.420 [] - Errors:   0

  5.   [INFO] 2018-01-14 22:16:31.420 [] - Thread Count: 2

  6.   [INFO] 2018-01-14 22:16:31.421 [] - Warm up:      0ms

  7.   [INFO] 2018-01-14 22:16:31.421 [] - Execution time: 1000ms

  8.   [INFO] 2018-01-14 22:16:31.421 [] - Throughput:     10/s (Required: -1/s) - PASSED

  9.   [INFO] 2018-01-14 22:16:31.424 [] - Min latency:   200.2112ms (Required: -1.0ms) - PASSED

  10.   [INFO] 2018-01-14 22:16:31.424 [] - Max latency:    205.67862ms (Required: -1.0ms) - PASSED

  11.   [INFO] 2018-01-14 22:16:31.425 [] - Ave latency:    202.97829ms (Required: -1.0ms) - PASSED</font>
复制代码
HTML 形式
[attach]144007[/attach]







欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2