Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Give a simplest way to find out the time a method takes for execution without using any profiling tool?
Give a simplest way to find out the time a method takes for execution without using any profiling tool?
✍: Guest
Read the system time just before the method is invoked and immediately after method returns. Take the time difference, which will give you the time taken by a method for execution.
To put it in code...
long start = System.currentTimeMillis ();
method ();
long end = System.currentTimeMillis ();
System.out.println ("Time taken for execution is " + (end - start));
Remember that if the time taken for execution is too small, it might show that it is taking zero milliseconds for execution. Try it on a method which is big enough, in the sense the one which is doing considerable amout of processing.
2013-05-24, 1884👍, 0💬
Popular Posts:
What invokes a thread's run() method? After a thread is started, via its start() method of the Threa...
How can I enable session tracking for JSP pages if the browser has disabled cookies? We know that se...
How do you estimate maintenance project and change requests?
How To Use Subqueries with the IN Operator? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqu...
Can you explain the fundamentals of “GetGlobalResourceObject ”and “GetLocalResourceObject” function...