ChineseTony commented on PR #7748:
URL: https://github.com/apache/rocketmq/pull/7748#issuecomment-1994562169

   `
   @BenchmarkMode(Mode.Throughput)
   @Warmup(iterations = 3, time = 1)
   @Measurement(iterations = 5, time = 3)
   @Fork(1)
   @State(value = Scope.Benchmark)
   @OutputTimeUnit(TimeUnit.SECONDS)
   public class BooleanTest {
   
       private GetRouteInfoRequestHeader requestHeader1;
   
       @Setup
       public void init() {
           requestHeader1 = new GetRouteInfoRequestHeader();
           requestHeader1.setAcceptStandardJsonOnly(true);
       }
   
   
       @Benchmark
       @Threads(1)
       public void usingOptionalTest() {
           usingOptional();
       }
   
       @Benchmark
       @Threads(1)
       public void usingOptionalUsingUnnecessaryBoxingTest() {
           usingOptionalUsingUnnecessaryBoxing();
       }
   
   
       @Benchmark
       @Threads(1)
       public void usingBooleanTureTest() {
           usingBooleanTure();
       }
   
   
       public void  usingOptional(){
           Boolean standardJsonOnly = 
Optional.ofNullable(requestHeader1.getAcceptStandardJsonOnly())
                   .orElse(false);
           if (standardJsonOnly) {
   
           }
   
       }
   
       public void  usingOptionalUsingUnnecessaryBoxing(){
           boolean standardJsonOnly = 
Optional.ofNullable(requestHeader1.getAcceptStandardJsonOnly())
                   .orElse(false);
           if (standardJsonOnly) {
   
           }
       }
   
       public void usingBooleanTure(){
           boolean standardJsonOnly = 
Boolean.TRUE.equals(requestHeader1.getAcceptStandardJsonOnly());
           if (standardJsonOnly) {
   
           }
       }
   
   
       class GetRouteInfoRequestHeader {
   
           private String topic;
   
           private Boolean acceptStandardJsonOnly;
   
           public String getTopic() {
               return topic;
           }
   
           public void setTopic(String topic) {
               this.topic = topic;
           }
   
           public Boolean getAcceptStandardJsonOnly() {
               return acceptStandardJsonOnly;
           }
   
           public void setAcceptStandardJsonOnly(Boolean 
acceptStandardJsonOnly) {
               this.acceptStandardJsonOnly = acceptStandardJsonOnly;
           }
       }
   
       public static void main(String[] args) throws RunnerException {
           Options opt = new OptionsBuilder()
                   .include(BooleanTest.class.getSimpleName())
                   .addProfiler(StackProfiler.class)
                   .result("result.json")
                   .resultFormat(ResultFormatType.JSON).build();
           new Runner(opt).run();
       }
   
   }
   `
   <img width="1175" alt="image" 
src="https://github.com/apache/rocketmq/assets/24618786/fa68b4f2-1eec-45b5-b3b6-df0c0082f531";>
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to