Hello! How can I measure time of executing of this program? Thanks!
package hanoi;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
final byte size = 35;
Tower t = new Tower(size);
t.MoveTower(size, 1, 3, 2);
System.out.println(t.getSteps());
System.out.println(Math.pow(2, size) - 1);
}
}
1
Expert's answer
2012-04-12T09:48:21-0400
package hanoi; public class Test { /** * @param args */ public static void main(String[] args) { final byte size = 35; Tower t = new Tower(size); //detect the initial time int start = (int)System.currentTimeMillis(); t.MoveTower(size, 1, 3, 2); //detect execution time int time = (int)(System.currentTimeMillis() - start); System.out.println(t.getSteps()); System.out.println(Math.pow(2, size) - 1); System.out.println("Execution time:" +time); } }
Comments
Leave a comment