Often time we need to calculate the program elapsed or execution time in performance test. Here i share a tiny example to calculate it in milliseconds

import java.util.Date;
 
public class TimeMillisecond {
  public static void main(String[] argv) {
 
      long lStartTime = new Date().getTime(); //start time
 
      String sArray1[] = createArray(); //method execute
 
      long lEndTime = new Date().getTime(); //end time
 
      long difference = lEndTime - lStartTime; //check different
 
      System.out.println("Elapsed milliseconds: " + difference);
 
  }
 
  static String [] createArray(){
 
	  String sArray[] = new String [100000];
 
	  for(int i=0; i<100000; i++)
		  sArray[i] = "Array " + i;
 
	  return sArray;
  }
}
Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world\'s largest enterprise software company.
Publisher : Oracle Corporation