| 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: 3011
|
|
|
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
Bartender
Joined: Aug 16, 2005
Posts: 12929
|
|
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);
|
 |
 |
|
|
subject: time of execution
|
|
|