Answer to Question #8247 in Java | JSP | JSF for Bill

Question #8247
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);
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS
paypal