stoty commented on PR #7313:
URL: https://github.com/apache/hbase/pull/7313#issuecomment-3307137189

   According to my benchmark, there is no perf implication for removing final:
   
   `
   import java.util.Date;
   
   public class MicroBenchmark {
   
       static class TestWithFinal {
           private static final boolean a = true;
   
           public static int get() {
               if (a) {
                   return 1;
               } else {
                   return 0;
               }
           }
       }
   
       static class TestWithoutFinal {
           private static boolean a = true;
   
           public static int get() {
               if (a) {
                   return 1;
               } else {
                   return 0;
               }
           }
       }
   
       public static void main(String[] args) {
           long count = 4000000000l;
           long sum = 0;
           long start = (new Date()).getTime();
           for (long i = 0; i < count; i++) {
               sum += TestWithFinal.get();
           }
           System.out.println("final:" + ((new Date()).getTime() - start) + 
"ms" + " sum:" + sum);
   
           sum = 0;
           long start2 = (new Date()).getTime();
           for (long i = 0; i < count; i++) {
               sum += TestWithoutFinal.get();
           }
           System.out.println("no final:" + ((new Date()).getTime() - start2) + 
"ms" + " sum:" + sum);
   
           sum = 0;
           long start3 = (new Date()).getTime();
           for (long i = 0; i < count; i++) {
               sum += TestWithFinal.get();
           }
           System.out.println("final:" + ((new Date()).getTime() - start3) + 
"ms" + " sum:" + sum);
   
           sum = 0;
           long start4 = (new Date()).getTime();
           for (long i = 0; i < count; i++) {
               sum += TestWithoutFinal.get();
           }
           System.out.println("no final:" + ((new Date()).getTime() - start4) + 
"ms" + " sum:" + sum);
       }
   }
   `


-- 
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: issues-unsubscr...@hbase.apache.org

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

Reply via email to