my dog learned polymorphism*
The moose likes Beginning Java and the fly likes measuring the execution time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "measuring the execution time " Watch "measuring the execution time " New topic
Author

measuring the execution time

lakmal padmakumara
Ranch Hand

Joined: Aug 08, 2009
Posts: 47
Hey I want to measure the executing time of my application .It means after a particular time it should perform some specific tasks.So how can i measure the time from the start .I mean if you can provide me with an idea i may be bale to search and develop to a solution .
Thanks !!!


[Bsc in Computer Science and Engineering] [SCJP 80%][BCS certificate level]
Miklos Szeles
Ranch Hand

Joined: Oct 21, 2008
Posts: 142
You can use System.currentTimeMillis() or System.nanoTime()measure starting and ending time.
David Kilcy
Greenhorn

Joined: Aug 25, 2009
Posts: 20
If you are using linux you can use the 'time' command. See "man time"
But personally I prefer Miklos suggestion to use currentTimeMillis and find the delta
Ireneusz Kordal
Ranch Hand

Joined: Jun 21, 2008
Posts: 423
SheduledPoolExecutor or Timer could be used to start a task in a separate thread after a given delay.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38465
    
  23
Your question is not at all clear. Measuring execution time and starting a second task after a certain delay are two completely different things.
lakmal padmakumara
Ranch Hand

Joined: Aug 08, 2009
Posts: 47
ok this is for those who are not clear with my question.What I want is to execute some commands after a particular time of execution.If i simplify it ,as an example I want to print "My name is Lakmal" after 30 seconds ,stopping all the other current executing instructions.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38465
    
  23
You have already been told about Timers. I don't think it is possible to stop everything else, however.

Anybody else know better?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: measuring the execution time