Total members 10261 | Gratitudes |It is currently Wed May 23, 2012 7:48 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 2 posts ] 
Author Question
 Question subject: calculating time required to execute function
PostPosted: Thu Oct 23, 2008 12:52 am 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:47 pm
Posts: 281
Has thanked: 0 time
Have thanks: 1 time

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


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: calculating time required to execute function
PostPosted: Thu Oct 23, 2008 12:57 am 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:53 pm
Posts: 229
Has thanked: 0 time
Have thanks: 0 time
Before function call:-
long startTime = System.currentTimeMillis();

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


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 2 posts ] 
Quick reply


  

 Similar topics
 @NamedNativeQuery:SQLGrammarException could not execute quer
 Plz Help,I want BOTH THREAD to work at a time in SAME WINDOW
 Selecting a Domain Name at the Time of Registration
 login using sessionid or time
 execute if else simultaneously
 Time countdown
 srand function example
 Having a hard time with this class need help deseperately.
 calculate the load time for a page
 recursively calculating factorial

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: Google Adsense [Bot] and 2 guests



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team