Is there a command in java to measure the execution time?
问题 Is there a command in java to measure the execution time ? Something like System.out.println(execution.time); in the end of the code. 回答1: Here is a complete and little modified example on how you could do that: public class ExecutionTimer { private long start; private long end; public ExecutionTimer() { reset(); start = System.currentTimeMillis(); } public void end() { end = System.currentTimeMillis(); } public long duration(){ return (end-start); } public void reset() { start = 0; end = 0;