xuminwlt commented on issue #1838: cglib FastInvoke replace the jdk Invoke URL: https://github.com/apache/incubator-shardingsphere/pull/1838#issuecomment-458496750 @terrymanu I change my test in JMH env at 1.8, the invoke is almost the same to fastMethod, or better, i agree that it's not the performance bottleneck in which user scenario, i'll do more try. thanks. The test code ``` @OutputTimeUnit(TimeUnit.MILLISECONDS) @BenchmarkMode(Mode.AverageTime) @Benchmark @SneakyThrows public void jdk() { PreparedStatement preparedStatement = new PreparedStatement(); for (int i = 0 ;i <= 10000 ; i++) { JdbcMethodInvocation actual = new JdbcMethodInvocation(PreparedStatement.class.getMethod("setObject", int.class, Object.class), new Object[] {1, 100}); actual.invoke(preparedStatement); } } @OutputTimeUnit(TimeUnit.MILLISECONDS) @BenchmarkMode(Mode.AverageTime) @Benchmark @SneakyThrows public void cgilib() { PreparedStatement preparedStatement = new PreparedStatement(); for (int i = 0 ;i <= 10000 ; i++) { JdbcFastMethodInvocation actual = new JdbcFastMethodInvocation(JdbcFastMethodInvocation.build(PreparedStatement.class, PreparedStatement.class.getMethod("setObject", int.class, Object.class)), new Object[] {1, 100}); actual.invoke(preparedStatement); } } ``` The JMH result ``` # JMH version: 1.19 # VM version: JDK 1.8.0_101, VM 25.101-b13 # VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/jre/bin/java # VM options: -Didea.launcher.port=7537 -Didea.launcher.bin.path=/Applications/IntelliJ IDEA 15.app/Contents/bin -Dfile.encoding=UTF-8 # Warmup: 10 iterations, 1 s each # Measurement: 10 iterations, 1 s each # Timeout: 10 min per iteration # Threads: 1 thread, will synchronize iterations # Benchmark mode: Average time, time/op # Benchmark: me.j360.tools.ref.MethodInoveBenchmark.cgilib # Run progress: 0.00% complete, ETA 00:00:40 # Fork: 1 of 1 # Warmup Iteration 1: 17.867 ms/op # Warmup Iteration 2: 5.198 ms/op # Warmup Iteration 3: 3.838 ms/op # Warmup Iteration 4: 3.848 ms/op # Warmup Iteration 5: 3.705 ms/op # Warmup Iteration 6: 3.739 ms/op # Warmup Iteration 7: 3.726 ms/op # Warmup Iteration 8: 3.870 ms/op # Warmup Iteration 9: 4.008 ms/op # Warmup Iteration 10: 4.075 ms/op Iteration 1: 4.639 ms/op Iteration 2: 4.027 ms/op Iteration 3: 4.513 ms/op Iteration 4: 4.916 ms/op Iteration 5: 4.685 ms/op Iteration 6: 5.879 ms/op Iteration 7: 4.482 ms/op Iteration 8: 4.685 ms/op Iteration 9: 6.009 ms/op Iteration 10: 4.347 ms/op Result "me.j360.tools.ref.MethodInoveBenchmark.cgilib": 4.818 ±(99.9%) 0.966 ms/op [Average] (min, avg, max) = (4.027, 4.818, 6.009), stdev = 0.639 CI (99.9%): [3.852, 5.784] (assumes normal distribution) # JMH version: 1.19 # VM version: JDK 1.8.0_101, VM 25.101-b13 # VM invoker: /Library/Java/JavaVirtualMachines/jdk1.8.0_101.jdk/Contents/Home/jre/bin/java # VM options: -Didea.launcher.port=7537 -Didea.launcher.bin.path=/Applications/IntelliJ IDEA 15.app/Contents/bin -Dfile.encoding=UTF-8 # Warmup: 10 iterations, 1 s each # Measurement: 10 iterations, 1 s each # Timeout: 10 min per iteration # Threads: 1 thread, will synchronize iterations # Benchmark mode: Average time, time/op # Benchmark: me.j360.tools.ref.MethodInoveBenchmark.jdk # Run progress: 50.00% complete, ETA 00:00:21 # Fork: 1 of 1 # Warmup Iteration 1: 5.571 ms/op # Warmup Iteration 2: 4.945 ms/op # Warmup Iteration 3: 4.338 ms/op # Warmup Iteration 4: 4.210 ms/op # Warmup Iteration 5: 4.345 ms/op # Warmup Iteration 6: 4.241 ms/op # Warmup Iteration 7: 4.247 ms/op # Warmup Iteration 8: 4.315 ms/op # Warmup Iteration 9: 4.319 ms/op # Warmup Iteration 10: 4.264 ms/op Iteration 1: 4.257 ms/op Iteration 2: 4.541 ms/op Iteration 3: 4.273 ms/op Iteration 4: 4.280 ms/op Iteration 5: 4.319 ms/op Iteration 6: 4.295 ms/op Iteration 7: 4.374 ms/op Iteration 8: 4.387 ms/op Iteration 9: 4.318 ms/op Iteration 10: 4.353 ms/op Result "me.j360.tools.ref.MethodInoveBenchmark.jdk": 4.340 ±(99.9%) 0.125 ms/op [Average] (min, avg, max) = (4.257, 4.340, 4.541), stdev = 0.083 CI (99.9%): [4.215, 4.465] (assumes normal distribution) # Run complete. Total time: 00:00:41 Benchmark Mode Cnt Score Error Units MethodInoveBenchmark.cgilib avgt 10 4.818 ± 0.966 ms/op MethodInoveBenchmark.jdk avgt 10 4.340 ± 0.125 ms/op ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
