Re: How Do You Tell How Long it Takes for a Piece of Code to Execute?
- From: "Thomas Fritsch" <i.dont.like.spam@xxxxxxxxxxx>
- Date: Tue, 18 Jul 2006 03:12:35 +0200
<kvnsmnsn@xxxxxxxxxxx> wrote:
I've been looking at classes <Time>, <Date>, and <Calendar>, trying toAlthough you get a milliseconds value, that usually doesn't mean that this
figure out how to time how long it takes my program to execute, but
without any luck. What I want to do is store a time value at the be-
ginning of my program, and then store a time value at the end of my
program, and then at the end of my program subtract the two values and
come up with how many milliseconds passed while the program was exe-
cuting.
For a bit I thought I could simply call the <getTime()> method of
class <Date> twice to accomplish this, since that method is supposed
to give the number of milliseconds transpired since 1 January 1970,
but no matter how long it takes for my program to run when I subtract
the two values I always get zero.
value is accurate by 1 millisec. Depending on your OS you might always get a
multiple of say 50, because the system clock ticks once every 50 millisecs.
See also the API doc of System.currentTimeMillis()
--
Thomas
.
- References:
- Prev by Date: Re: How Do You Tell How Long it Takes for a Piece of Code to Execute?
- Next by Date: Re: java.lang.SecurityException: Prohibited package name: java
- Previous by thread: Re: How Do You Tell How Long it Takes for a Piece of Code to Execute?
- Next by thread: Re: How Do You Tell How Long it Takes for a Piece of Code to Execute?
- Index(es):
Relevant Pages
|