measuring elapsed time using Spring StopWatch
package Core; import org.springframework.util.StopWatch; public class ExecutionTimeStopWatch { void method() throws InterruptedException { System.out.println("Execution Start"); Thread.sleep(2000); int b = 12+7*88/9; System.out.println("Execution End "+ b); } public static void main(String[] args) { try { StopWatch watch = new StopWatch(); ExecutionTime obj = new ExecutionTime(); watch.start(); obj.method(); watch.stop(); System.out.println("Time Taken: "+ watch.getTotalTimeMillis()); } catch (InterruptedException e) { e.printStackTrace(); } } }
0 comments:
Post a Comment