/* * Timer.java * * Created on April 12, 2005, 10:29 PM */ package sorttimer; /** * * @author levenick */ public class Timer { AbstractSort theSort; MyList theList; /** Creates a new instance of Timer */ public Timer(AbstractSort theSort, MyList theList) { this.theSort = theSort; this.theList = theList; } public String time(int n) { long before = System.currentTimeMillis(); theSort.sort(theList) ; long after = System.currentTimeMillis(); long elapsedTime = after - before; return theSort.toString() + " n=" + n + " msec=" + elapsedTime; } }