BladeX如何整合JMH,希望给个例子

Blade 未结 1 989
zkf
zkf 2020-06-01 16:45
悬赏:20

一、该问题的重现步骤是什么?

  1. 引入jmh依赖。 

    org.openjdk.jmh
    jmh-core
    1.21


    org.openjdk.jmh
    jmh-generator-annprocess
    1.21
    provided


2. 配置jmh测试类


(BladeSpringRunner.)
(classes = DemoApplication.)
(appName = ,profile = ,enableLoader = )
(Scope.)JmhSpringBootTest {

   ConfigurableApplicationContext ;

   BlogServiceImpl ;

   main(String[] args) RunnerException {
      Options options=OptionsBuilder().include(JmhSpringBootTest..getName()+)
         .warmupIterations().measurementIterations().forks().build();
      Runner(options).run();
   }

   (Level.)
   init(){
      String arg=;
      = SpringApplication.(DemoApplication., arg);
      = .getBean(BlogServiceImpl.);
   }

   test(){
      System..println(.getStudent());
   }
}

二、你期待的结果是什么?实际看到的又是什么?

我期待能够实现运行,并测试出结果。但是并没有看到结果,最后是无法运行。


三、你正在使用的是什么产品,什么版本?在什么操作系统上?


BladeX.2.5   win10系统64位  



四、请提供详细的错误堆栈信息,这很重要。


Connected to the target VM, address: '127.0.0.1:50712', transport: 'socket'

# JMH version: 1.21

# VM version: JDK 1.8.0_121, Java HotSpot(TM) 64-Bit Server VM, 25.121-b13

# VM invoker: D:\develop\java\jdk\jre\bin\java.exe

# VM options: -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:50712,suspend=y,server=n -javaagent:C:\Users\aiwen\.IntelliJIdea2019.3\system\captureAgent\debugger-agent.jar -Dfile.encoding=UTF-8

# Warmup: 2 iterations, 10 s each

# Measurement: 2 iterations, 10 s each

# Timeout: 10 min per iteration

# Threads: 1 thread, will synchronize iterations

# Benchmark mode: Throughput, ops/time

# Benchmark: org.springBlade.test.JmhSpringBootTest.test


# Run progress: 0.00% complete, ETA 00:00:40

# Fork: 1 of 1

ERROR: transport error 202: connect failed: Connection refused

ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)

JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]

ERROR: transport error 202: connect failed: Connection refused

ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)

JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]


# Run complete. Total time: 00:00:00


REMEMBER: The numbers below are just data. To gain reusable insights, you need to follow up on

why the numbers are the way they are. Use profilers (see -prof, -lprof), design factorial

experiments, perform baseline and negative tests that provide experimental control, make sure

the benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the domain experts.

Do not assume the numbers tell you what you want them to tell.


Benchmark  Mode  Cnt  Score   Error  Units

Disconnected from the target VM, address: '127.0.0.1:50712', transport: 'socket'


Process finished with exit code 0


五、若有更多详细信息,请在下面提供。

1条回答
  •  如梦技术
    2020-06-02 17:04

    jmh 不适合做微服务测试,比较适合做组件的测试。微服务建议 jmeter 测试下就好。具体性能问题可以结合  的Trace进行分析。

    0 讨论(0)
提交回复