• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

time of execution

 
Puneet N Vyas
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How big a difference are you seeing in the times ? No program will have the same execution time every time it runs.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bill Shirley
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic