package com.xdclass.couponapp; import com.xdclass.couponapp.service.CouponService; import org.openjdk.jmh.annotations.*; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.ConfigurableApplicationContext; @State(Scope.Thread) public class JMHSpringBootTest { private ConfigurableApplicationContext context; private CouponService couponService; public static void main(String[] args) throws RunnerException { Options options = new OptionsBuilder().include(JMHSpringBootTest.class.getName()+".*") .warmupIterations(2).measurementIterations(2).forks(1).build(); new Runner(options).run(); } /** * setup初始化容器的时候只执行一次 */
Springboot整合JMH基准测试
最新推荐文章于 2023-08-10 16:34:43 发布