5 Replies Latest reply on Jun 28, 2012 11:52 AM by EJP

    Performance Issue in NetworkInterface.getNetworkInterface in windows JRE 7

    945046
      NetworkInterface.getNetworkInterface() call takes 10 times more time when run in Windows JRE 7. The same call runs much faster in JRE 6.

      Sample Program,
      I wrote a small program which just fetches the network interfaces using java.net.NetworkInterface.getNetworkInterfaces() as below,

      ------------------------------------ Program Start ------------------------------------
      import java.net.*;
      import java.util.*;

      public class PerfNetTest {

      public static void main(String args[]) throws Exception {
           long startTime = System.currentTimeMillis();     
           Enumeration niEnum = NetworkInterface.getNetworkInterfaces();          
           long endTime = System.currentTimeMillis();     
           System.out.println ( "Total Time Taken For One Call: " + (endTime-startTime));          
           
           startTime = System.currentTimeMillis();          
           for (int i = 0; i < 10; i++) {
                niEnum = NetworkInterface.getNetworkInterfaces();
           }
           endTime = System.currentTimeMillis();     
           System.out.println ( "Total Time Taken For Ten Call: " + (endTime-startTime));          
      }     
      }
      ------------------------------------ Program End ------------------------------------

      Compiled the above code in Java 6 and ran the above program in JRE 6 and JRE 7. JRE 7 takes approximately 10 times more time than JRE 6. This leads to a huge performance issue in our project.

      I ran it 5 times in each JRE versions and below are the test results,

      When run in JRE 6

      c:\test\net>java PerfNetTest
      Total Time Taken For One Call: 18
      Total Time Taken For Ten Call: 81

      c:\test\net>java PerfNetTest
      Total Time Taken For One Call: 17
      Total Time Taken For Ten Call: 80

      c:\test\net>java PerfNetTest
      Total Time Taken For One Call: 19
      Total Time Taken For Ten Call: 80

      c:\test\net>java PerfNetTest
      Total Time Taken For One Call: 18
      Total Time Taken For Ten Call: 79

      c:\test\net>java PerfNetTest
      Total Time Taken For One Call: 18
      Total Time Taken For Ten Call: 80
      -------

      When run in JRE 7

      c:\test\net>java PerfNetTest
      Total Time Taken For One Call: 98
      Total Time Taken For Ten Call: 891

      c:\test\net>java PerfNetTest
      Total Time Taken For One Call: 100
      Total Time Taken For Ten Call: 869

      c:\test\net>java PerfNetTest
      Total Time Taken For One Call: 98
      Total Time Taken For Ten Call: 859

      c:\test\net>java PerfNetTest
      Total Time Taken For One Call: 99
      Total Time Taken For Ten Call: 871

      c:\test\net>java PerfNetTest
      Total Time Taken For One Call: 99
      Total Time Taken For Ten Call: 888

      --------
      Is there any other way to optimize the performance in JRE 7 internally, Can the above issue considered as a bug with Windows JRE 7? Can I go and submit a bug for this?