wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes time of execution Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "time of execution " Watch "time of execution " New topic
Author

time of execution

Puneet N Vyas
Ranch Hand

Joined: Sep 20, 2007
Posts: 61
i have used time of execution class to know the time of execution of the operation,but upon running the program different times it gives different time of execution,can any one tell why it is happening or anyother way to get the time of execution


thanks for support
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3420
    
  12
How big a difference are you seeing in the times ? No program will have the same execution time every time it runs.


Joanne
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14074
    
  16

Note that the accuracy of the timer used by System.currentTimeMillis() is not very good on some operating systems. So if you time very short events, you will not get very accurate time measurements if you use this.

If you're using Java 5 or newer, you could use System.nanoTime() instead, which will probably use a more accurate timer, but even that timer does not have a guaranteed accuracy.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
The time of execution should not be expected to be a constant.

If you're playing video on your machine, and defragging the hard drive, it will effect other processes. All machines are running many, many processes, and they're all sharing the resources.


Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: time of execution
 
Similar Threads
Hashtable vs Hashmap
Applet timer
Needs Explanation
Are ints better?
Easy stringbuffer questions