top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Give a simplest way to find the time a method takes for execution without using any profiling tool?

+2 votes
170 views
Give a simplest way to find the time a method takes for execution without using any profiling tool?
posted Sep 15, 2013 by Arvind Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Read the system time just before the method is invoked and immediately after method returns take the time difference,which 'll give you the time taken by a method for execution.
use this code.....

long start=System.currentTimeMillis();
method();
long end=System.currentTimeMillis();
System.out.println("Time taken for execution is"+(end-start));
answer Sep 15, 2013 by Vinay Shukla
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...