
timeMeasure
By:
DoNgocDuc on
Aug 3rd, 2012 | syntax:
Java | size: 0.71 KB | hits: 18 | expires: Never
//class Date is used to retrieve the current system time
import java.util.Date;
public class TimeMeasure
{
public void TimeMeasure()
{
//retrieve system time before the sorting
long timebuf1 = (new Date()).getTime();
//this is the command to conduct the sorting. It can be replaced by bubbleSort, quickSort etc. to suit each test
Sort(S_large, 0,S_large.length-1);
//retrieve system time after the sorting, and then take the difference of the time before and after the sort
long smallTime1 = (new Date()).getTime() - timebuf1;
//display the time taken to do the sorting
System.out.println("Time taken for quicksort: " + smallTime1 + " ms");
}
}