You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2019/09/16 03:37:16 UTC

[GitHub] [incubator-shardingsphere] yanyzy commented on issue #3034: Optimize performance, reduce unnecessary loops

yanyzy commented on issue #3034: Optimize performance, reduce unnecessary loops
URL: https://github.com/apache/incubator-shardingsphere/pull/3034#issuecomment-531631589
 
 
   @tuohai666 I tested it locally using the following code
   
   ```java
   @Test
       public void valueOfBenchmark() {
           int[] commands = new int[100_0000];
           for (int i = 0; i < 100_0000; i++) {
               commands[i] = random.nextInt(31);
           }
   
           Stopwatch stopwatch = Stopwatch.createStarted();
           for (int i = 0; i < 100_0000; i++) {
               MySQLCommandPacketType.valueOf(commands[i]);
           }
           System.out.println("1st Time of execution in MILLISECONDS:" + stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
   
           stopwatch = Stopwatch.createStarted();
           for (int i = 0; i < 100_0000; i++) {
               MySQLCommandPacketType.valueOfOrigin(commands[i]);
           }
           System.out.println("2st Time of execution in MILLISECONDS:" + stopwatch.stop().elapsed(TimeUnit.MILLISECONDS));
       }
   ```
   and the result of the operation is:
   1st Time of execution in MILLISECONDS:12
   2st Time of execution in MILLISECONDS:50

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services