Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Test and Performance Tools Platform (TPTP) » Is "Cumulative CPU time" supposed to be the same from run to run?
Is "Cumulative CPU time" supposed to be the same from run to run? [message #120974] Wed, 16 January 2008 21:57 Go to next message
Eclipse UserFriend
Originally posted by: dinogg.gmail.com

I'm a newbie at tptp (4.4.0.3 all in one) and couldn't find any info on
this in the docs or newsgroup. So here I go...

When I profile my Swing-based Java application, I can choose to "Collect
method CPU time information". When I do that, I get a new column called
"Cumulative CPU Time" for each of the methods called.

Based on my limited experience with CPU time and JVMs, I would expect the
CPU time to be the same for a given method from run to run.

But I get a different values for the same method each time I run it.

Have I misunderstood the meaning of CPU time?

The next thing I'm going to try is remove Swing from the picture and
create a simple Java app instead.
Re: Is "Cumulative CPU time" supposed to be the same from run to run? [message #121061 is a reply to message #120974] Sun, 20 January 2008 09:22 Go to previous messageGo to next message
Asaf Yaffe is currently offline Asaf YaffeFriend
Messages: 333
Registered: July 2009
Senior Member
dinogg,

The TPTP Profiler provides two "time" counters:

- "Execution Time" - always provided - shows the total "wall clock" time
it took the method to execute. This is computed by capturing the system
timer at the beginning and end of the method, and subtracting the "start
time" from the "end time".

- "CPU Time" - configurable - shows the actual time the method was
executing in the CPU. It should provide an estimate for the actual CPU
cycles used to execute this CPU, not counting idle time, context
switches etc. This value is captured from the JVM directly, using some
JVMTI functions (see GetThreadCPUTime function here:
http://java.sun.com/j2se/1.5.0/docs/guide/jvmti/jvmti.html#t imers).
The problem with CPU Time is that the data provided by the JVM is not
very accurate and is not granular enough. In fact, on most current JVMs,
any method which keeps the CPU busy for less than a millisecond (which
is quite a lot of CPU time on a modern CPU) will be reported with a CPU
time of 0. Therefore, I think this counter is not very usable.

HTH,
Asaf


--
Asaf Yaffe
Eclipse TPTP Committer, JVMTI Profiler
Re: Is "Cumulative CPU time" supposed to be the same from run to run? [message #121150 is a reply to message #121061] Mon, 21 January 2008 14:07 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dinogg.gmail.com

Great, thanks Asaf for letting me know.

Can I assume then that ThreadMXBean
( http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management /ThreadMXBean.html)
suffers from the same problem?

You did say most JVMs have this problem. Do you know how I can find out
which ones do/don't?
Re: Is "Cumulative CPU time" supposed to be the same from run to run? [message #121295 is a reply to message #121150] Thu, 24 January 2008 08:29 Go to previous message
Asaf Yaffe is currently offline Asaf YaffeFriend
Messages: 333
Registered: July 2009
Senior Member
Dino G wrote:
> Great, thanks Asaf for letting me know.
>
> Can I assume then that ThreadMXBean
> ( http://java.sun.com/j2se/1.5.0/docs/api/java/lang/management /ThreadMXBean.html)
> suffers from the same problem?
>
> You did say most JVMs have this problem. Do you know how I can find out
> which ones do/don't?
>

According to the documentation (in the link you provided):
"The CPU time provided by this interface has nanosecond precision but
not necessarily nanosecond accuracy"

This looks similar to JVMTI, and I won't be surprised if both methods
use the same JVM counters. However, you may want to post a question on
the Sun Java newsgroup to get more information.

As for finding which JVMs support CPU counter and at what precision -
this is probably a trial-and-error experience....
As far as I know, the implementation on Sun and JRockit is the same for
1.5 and 1.6.

HTH,
Asaf

--
Asaf Yaffe
Eclipse TPTP Committer, JVMTI Profiler
Previous Topic:Unable to profile Java application
Next Topic:Unable to associate multiple TestCases with an artifact
Goto Forum:
  


Current Time: Sun Nov 23 01:08:29 GMT 2014

Powered by FUDForum. Page generated in 0.03928 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software