• Post Reply Bookmark Topic Watch Topic
  • New Topic

Program running time  RSS feed

 
Jack Rudolf
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Heyy..
Could you help me how to make a time for running program?
It should start timing the moment we open the program until when we close it. It works like the timer in the mobile phone.
The value will be displayed in the JTextArea.
btw, Can we actually send the time to JLabel?

Thanks guys!!
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shall it work with different programs, or just with one?

If it works for just one program, it could be a part of the program, but of course couldn't exactly measure from before starting - end of program.
You could display the result in a dialog or frame, which has to be closed, after the rest of the program has finished and stopped the timer.

Another way would be to communicate over sockets, but in this case too, the program started running before sending the message.

Is exactness of milliseconds important?

The last question:
(untestet)
[ September 06, 2004: Message edited by: Stefan Wagner ]
 
Jack Rudolf
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shall it work with different programs, or just with one?
No, it just works on one program only...the exactness of the miliseconds is not important. it just need to be exact to seconds only.!! thanks!
 
Kedar Bhawarthi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
let me know if this trick helps you...

it will check approximate milliseconds spend for loop.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you could use the Jakarta Commons Lang StopWatch...
 
Jack Rudolf
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kedar, your method is working. but it does not reset and start from 0 at the starting of the program. It should start from 0 again after u have close the program.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!