There is no direct way to calculate the time of a mehtod which is in execution. But there is a method to calculate current time by which we can approx calculate the total time.
Class : System
Method : currentTimeMillis
Use:
Class : System
Method : currentTimeMillis
Use:
- public static void main(String[] args) {
- long startTime = System.currentTimeMillis();
- System.out.println(method(some_value));
- long endTime = System.currentTimeMillis();
- long totalTime = endTime - startTime;
- System.out.println("total time in milli seconds "(totalTime);
- }

0 comments:
Post a Comment