This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 62648 - Unacceptable variance of CPU results
Summary: Unacceptable variance of CPU results
Status: CLOSED WONTFIX
Alias: None
Product: profiler
Classification: Unclassified
Component: Base (show other bugs)
Version: 4.x
Hardware: All All
: P2 blocker (vote)
Assignee: issues@profiler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-19 10:26 UTC by ehucka
Modified: 2006-03-24 13:17 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ehucka 2005-08-19 10:26:23 UTC
build 050819 m8v2 jdk 1.5.0_04

I tried to profile simple method like:

private void test1000() {
    long startTime = System.currentTimeMillis();
    while ((System.currentTimeMillis() - startTime) < 1000);
}
 
The method is called periodicaly and always run 1000ms. I used CPU profiling
with this method as root method. The Live Results window shown me values:

1000ms 1st invocation
2002ms 2nd invocation
2999ms 3rd invocation
3593ms 4th invocation
...

The error on the last line is not exceptional, similar errors occured in about 3
invocations of 10.
Comment 1 ehucka 2005-08-24 14:13:58 UTC
I found that when 'getresults' is called in a time a method is entered but not
exited the profiler client probably counts a difference between method entry and
getresults time and adds it to the method's self time. (The difference is
subtracted after showing of results.) The method's invocations counter is
increased after the method is entered.

If a user take snapshot in a 'wrong' time profiler can return results:
10 invocations of a method (each should take 1000 ms) and self time 9536ms.

Maybe it should show only finished invocations of a method:

9 invocations, self time 9000ms or to have more counters:

9 invocations, 10 method's entries, measured time 9000ms, actual time 9536ms
Comment 2 iformanek 2005-08-30 16:51:21 UTC
The results are actually correct.

The results have to include partial results for methods that have not finished 
yet - definitely for submethods called, as those may have finished their 
execution, and if those are included, the self time needs to be included too 
for accuracy.

The clearest example is with methods that never exit - such as run () method or 
all threads - if partial timing would not be included, no results would be 
available until the thread finishes - which is never for most typical threads.
Comment 3 ehucka 2006-03-22 09:36:14 UTC
verified