01: import java.util.Scanner;
02: 
03: /**
04:    This program measures how long it takes to sort an
05:    array of a user-specified size with the selection
06:    sort algorithm.
07: */
08: public class SelectionSortTimer
09: {  
10:    public static void main(String[] args)
11:    {  
12:       Scanner in = new Scanner(System.in);
13:       System.out.print("Enter array size: ");
14:       int n = in.nextInt();
15: 
16:       // Construct random array
17:    
18:       int[] a = ArrayUtil.randomIntArray(n, 100);
19:       SelectionSorter sorter = new SelectionSorter(a);
20:       
21:       // Use stopwatch to time selection sort
22:       
23:       StopWatch timer = new StopWatch();
24:       
25:       timer.start();
26:       sorter.sort();
27:       timer.stop();
28:       
29:       System.out.println("Elapsed time: " 
30:             + timer.getElapsedTime() + " milliseconds");
31:    }
32: }
33: 
34: