Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

measuring the execution time

 
lakmal padmakumara
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !!!
 
Miklos Szeles
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use System.currentTimeMillis() or System.nanoTime()measure starting and ending time.
 
David Kilcy
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 423
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SheduledPoolExecutor or Timer could be used to start a task in a separate thread after a given delay.
 
Campbell Ritchie
Sheriff
Posts: 48440
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 48440
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have already been told about Timers. I don't think it is possible to stop everything else, however.

Anybody else know better?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic