Friday, 23 August 2013

How to use the execution time method with try and catch

How to use the execution time method with try and catch

I am trying to measure the execution time, but i do not know where to but
the method is before the try block or inside??
ublic static void main(String[] args) {
long startTime = System.currentTimeMillis();
try {
SearchDetailsDialog dialog = new SearchDetailsDialog(null);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}long endTime = System.currentTimeMillis();
long totalTime = ((endTime - startTime)/1000);
System.out.println("the execution time is:");
System.out.println(totalTime);
}

No comments:

Post a Comment