iamhucong opened a new issue, #28602:
URL: https://github.com/apache/shardingsphere/issues/28602

   Based on the JMH test, the CaseInsensitiveMap in Apache Commons Collections 
demonstrates higher performance.
   ## JMH test code
   ```java
   @BenchmarkMode(Mode.AverageTime)
   @OutputTimeUnit(TimeUnit.NANOSECONDS)
   @Warmup(iterations = 5, time = 1)
   @Measurement(iterations = 5, time = 1)
   @Fork(3)
   @State(Scope.Benchmark)
   public class CaseInsensitiveMapBenchmarkRunner {
       public static void main(String[] args) throws IOException {
           org.openjdk.jmh.Main.main(args);
       }
       
       private Map<String, String> hashmap;
       private Map<String, String> caseInsensitiveMap;
       private Map<String, String> treeMap;
       private Collection<String> params;
       @Param({"10","100","1000","10000","100000"})
       private int size;
       
       @Setup(Level.Trial)
       public void setUp() {
           hashmap = new HashMap<>();
           caseInsensitiveMap = new CaseInsensitiveMap<>();
           treeMap = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
           params = new ArrayList<>();
           Instancio.of(String.class).stream().limit(size).forEach(s -> {
               hashmap.put(s.toLowerCase(), s);
               caseInsensitiveMap.put(s, s);
               treeMap.put(s, s);
               params.add(s);
           });
       }
       
       @Benchmark
       public void hashmap(Blackhole blackhole) {
           params.forEach(s -> blackhole.consume(hashmap.get(s.toLowerCase())));
       }
       
       @Benchmark
       public void caseInsensitiveMap(Blackhole blackhole) {
           params.forEach(s -> blackhole.consume(caseInsensitiveMap.get(s)));
       }
       
       @Benchmark
       public void treemap(Blackhole blackhole) {
           params.forEach(s -> blackhole.consume(treeMap.get(s)));
       }
       
   }
   ``` 
   <img width="1527" alt="image" 
src="https://github.com/apache/shardingsphere/assets/20391901/b91bdbca-db15-4bca-83c1-ef01b7a2a22c";>
   


-- 
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: 
[email protected]

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

Reply via email to