Don't like ads? PRO users don't see any ads ;-)
Guest

timeMeasure

By: DoNgocDuc on Aug 3rd, 2012  |  syntax: Java  |  size: 0.71 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //class Date is used to retrieve the current system time
  2. import java.util.Date;
  3. public class TimeMeasure
  4. {
  5.     public void TimeMeasure()
  6.     {
  7.         //retrieve system time before the sorting
  8.         long timebuf1 = (new Date()).getTime();
  9.         //this is the command to conduct the sorting. It can be replaced by bubbleSort, quickSort etc. to suit each test
  10.         Sort(S_large, 0,S_large.length-1);
  11.         //retrieve system time after the sorting, and then take the difference of the time before and after the sort
  12.         long smallTime1 = (new Date()).getTime() - timebuf1;
  13.         //display the time taken to do the sorting
  14.         System.out.println("Time taken for quicksort: " + smallTime1 + " ms");
  15.     }
  16. }