Re: Get performance statistics?
Patricia Shanahan wrote:
Daniel Pitts wrote:
Patricia Shanahan wrote:
I would like to collect, inside a Java application, statistics such as
the amount of CPU time used. Any idea how?
I can, of course, measure the elapsed time, but that does not tell me
how much time was spent actually computing vs. waiting for disk.
Patricia
A quick googling leads me to believe you might need to use JNI (and
therefore have a platform-specific solution)
<http://www.google.com/search?q=java+system+monitoring>
Example for CPU on Win32
<http://www.javaworld.com/javaworld/javaqa/2002-11/01-qa-1108-cpu.html>
Yup, this mirrors the results of my searching.
Can anyone recommend a good tutorial on making JNI code portable? I need
to make this work on MS-WindowsXP, Linux with 32-bit JVM, and Linux with
64-bit JVM.
Patricia
My guess is that what you want specifically is only obtainable through
platform specific means. You'll have to write the platform specifics
for finding the current disk load, but the rest can be portable.
I also think that the code could be the same for both the Linux
versions (it would just need to be compiled for both). so you'll
probably just need two "versions". You might be able to use #ifdef
directives to have one source that compiles differently on
windows/linux. If you don't have much experience in C/C++, I would
suggest reading a quick primer.
Good luck,
Daniel.