Switch to full style
Java2 codes,problems ,discussions and solutions are here
Post a reply

calculating time required to execute function

Thu Oct 23, 2008 12:52 am

Hi
i have written program for different sorting algorithm each containing
in separate function.

I want to calculate time required to execute each sorting algo. I used
Date class method getTime() to get time before execution & after
execution by creating new object of Date. & Take difference of these two.

But function execute in us & gettime() returns millisecond.

Is there any way to calculate exact time required for each function.
Please explain ur answer



Re: calculating time required to execute function

Thu Oct 23, 2008 12:57 am

Before function call:-
Code:
long startTime = System.currentTimeMillis();


After function call:-
Code:
long stopTime = System.currentTimeMillis();
System.out.println("Exceution time = " + (stopTime-startTime) );


Post a reply
  Related Posts  to : calculating time required to execute function
 recursively calculating factorial     -  
 Calculating image Gradient     -  
 execute if else simultaneously     -  
 Execute System Commands     -  
 @NamedNativeQuery:SQLGrammarException could not execute quer     -  
 Which language is required to set up a web application?     -  
 Fatwire professionals required - Large MNC     -  
 Software Best Practices Training topics required     -  
 convert char*(number) to required unsigned char*     -  
 What Time Is It?     -  

Topic Tags

Java Time