rtista commented on pull request #3365:
URL: https://github.com/apache/activemq-artemis/pull/3365#issuecomment-751358300


   Hey guys, hope you all had a Merry Christmas! ;)
   
   @franz1981 I was able to implement the JMH tests you were looking for I 
think, here's the class I created:
   
   ```java
   /*
    * Licensed to the Apache Software Foundation (ASF) under one or more
    * contributor license agreements. See the NOTICE file distributed with
    * this work for additional information regarding copyright ownership.
    * The ASF licenses this file to You under the Apache License, Version 2.0
    * (the "License"); you may not use this file except in compliance with
    * the License. You may obtain a copy of the License at
    *
    *     http://www.apache.org/licenses/LICENSE-2.0
    *
    * Unless required by applicable law or agreed to in writing, software
    * distributed under the License is distributed on an "AS IS" BASIS,
    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    * See the License for the specific language governing permissions and
    * limitations under the License.
    */
   package org.apache.activemq.artemis.tests.performance.jmh;
   
   import java.util.concurrent.TimeUnit;
   
   import org.openjdk.jmh.annotations.Benchmark;
   import org.openjdk.jmh.annotations.BenchmarkMode;
   import org.openjdk.jmh.annotations.Fork;
   import org.openjdk.jmh.annotations.Measurement;
   import org.openjdk.jmh.annotations.Mode;
   import org.openjdk.jmh.annotations.OutputTimeUnit;
   import org.openjdk.jmh.annotations.Param;
   import org.openjdk.jmh.annotations.Scope;
   import org.openjdk.jmh.annotations.Setup;
   import org.openjdk.jmh.annotations.State;
   import org.openjdk.jmh.annotations.Warmup;
   
   public class CompositeAddressBenchmark {
   
       /* The FQQN separator */
       public static final String SEPARATOR = "::";
   
       /* The FQQN separator length */
       public static final int SEPARATOR_LENGTH = SEPARATOR.length();
   
       @State(Scope.Benchmark)
       public static class BenchmarkState {
   
           @Param({"address::queue", "address::", "::queue", "::"})
           public String queue;
       }
   
       /**
        * Code for isFullyQualified before Artemis-1883 changes.
        * @return boolean
        */
       @Benchmark
       @BenchmarkMode(Mode.AverageTime)
       @OutputTimeUnit(TimeUnit.NANOSECONDS)
       @Fork(value = 1, warmups = 1)
       @Warmup(iterations = 1)
       public static boolean isFullyQualifiedBefore(BenchmarkState state) {
           return state.queue != null && state.queue.contains(SEPARATOR);
       }
   
       /**
        * Code for isFullyQualified after Artemis-1883 changes.
        * @return boolean
        */
       @Benchmark
       @BenchmarkMode(Mode.AverageTime)
       @OutputTimeUnit(TimeUnit.NANOSECONDS)
       @Fork(value = 1, warmups = 1)
       @Warmup(iterations = 1)
       public static boolean isFullyQualifiedAfter(BenchmarkState state) {
   
           if (state.queue == null) {
               return false;
           }
   
           // If address length is incapable of holding the separator and two 
more characters
           if (state.queue.length() < SEPARATOR_LENGTH + 2) {
               return false;
           }
   
           // If separator is not found or is at the start or end of string 
then this is not a FQQN
           int index = state.queue.indexOf(SEPARATOR, 1);
           return index != -1 && index != state.queue.length() - 
SEPARATOR_LENGTH;
       }
   }
   ```
   
   And here are the results:
   ```
   # Run complete. Total time: 00:16:03
   
   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                                                (queue)  Mode  Cnt  
Score   Error  Units
   CompositeAddressBenchmark.isFullyQualifiedAfter   address::queue  avgt    5  
7.410 ± 1.155  ns/op
   CompositeAddressBenchmark.isFullyQualifiedAfter        address::  avgt    5  
7.954 ± 0.076  ns/op
   CompositeAddressBenchmark.isFullyQualifiedAfter          ::queue  avgt    5  
7.408 ± 0.086  ns/op
   CompositeAddressBenchmark.isFullyQualifiedAfter               ::  avgt    5  
3.026 ± 1.172  ns/op
   CompositeAddressBenchmark.isFullyQualifiedBefore  address::queue  avgt    5  
6.507 ± 0.106  ns/op
   CompositeAddressBenchmark.isFullyQualifiedBefore       address::  avgt    5  
6.407 ± 0.461  ns/op
   CompositeAddressBenchmark.isFullyQualifiedBefore         ::queue  avgt    5  
6.667 ± 1.218  ns/op
   CompositeAddressBenchmark.isFullyQualifiedBefore              ::  avgt    5  
6.378 ± 0.521  ns/op
   ```
   
   I haven't pushed the class code as I thought you'd probably want to mess 
with the warmup, fork and iterations parameters I guess in order to improve the 
results.
   
   Also, @franz1981  is there any way you can direct me to a framework for the 
E2E tests @michaelandrepearce is looking for?


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to