Click to See Complete Forum and Search --> : CPU time in Java


August 12th, 1999, 12:16 AM
Can anyone tell me how to calculate in Java the CPU time taken by a thread?

unicman
August 12th, 1999, 07:56 AM
I didn't get the meaning of CPU time.
Do u want to measure performance of the thread? If yes...

Way 1:
1) get the time-stamp before starting thread
2) start thread and wait till thread stops
3) get the time-stamp and compare it with the prev one

Way 2:
Assuming u do all the processing in 'run' method of the thread,
1) get the time-stamp at the first line in 'run' method
2) do all the processing
3) get the time-stamp and compare it with the prev one

If u don't want this, then I'm sorry.

- UnicMan
http://members.tripod.com/unicman