63 040
Assignments Done
99,1%
Successfully Done
In July 2018

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);
}

}
Expert's answer
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

Submit
Privacy policy Terms and Conditions