Thread timing: JVMPI GetCurrentThreadCpuTime?

B

Bryan

I'm trying to obtain per-thread timing information for my running
application. For example, I'd like to know the number of milliseconds
of CPU time thread X has been allocated so far.
System.currentTimeMillis gives me an approximation of this if I
serialize my thread activation, but it does not take into account
competition from other processes, blocks for I/O, etc.

The method that seems to be suggested most frequently is to use
JVMPI's GetCurrentThreadCpuTime from a chunk of native code. Under
Linux (kernel 2.4.20-18.9) and java 1.4.1 I do seem to get numbers
back (previous posters had reported only 0's being returned), however
the values do not seem to be thread-specific. All threads seem to be
sharing the same timer data. Has anyone used this successfully under
Linx?

Are there any other suggestions for obtaining high-resolution
per-thread timing information in Java under Linux?

Thanks.
 
R

Robert Olofsson

: Are there any other suggestions for obtaining high-resolution
: per-thread timing information in Java under Linux?

My profiler, jmp, http://www.khelekore.org/jmp, uses the times
function under linux to get current process times. Do "man times" to
read more about it. It is not as high resolution as the gettimeofday
(absolute time, not cpu time, not per thread).

In jmp it is possible to select between cpu time/thread and wall clock
time. Depending on what you want to measure. JMP is GPL so feel free
to download it and see what it does to measure time.

/robo
 
B

Bryan

Thanks. Is this something my process can call at runtime? What I
need is a way for the thread to
determine, for example, that it has been running for 2 seconds of CPU
time and therefore it should yield. I'm not so much interested in a
performance test as a way of doing dynamic time accounting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top