Red Gate forums :: View topic - Wrong time displayed
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
ANTS Performance Profiler 8
ANTS Performance Profiler 8 forum

Wrong time displayed

Search in ANTS Performance Profiler 8 forum
Post new topic   Reply to topic
Jump to:  
Author Message
BrcSen



Joined: 17 Jan 2014
Posts: 2

PostPosted: Fri Jan 17, 2014 1:30 pm    Post subject: Wrong time displayed Reply with quote

Hi
Im trying to profile some code in a backgroundworker (wpf application, .net 4.0 Client Profile). The pseudocode is:
Code:

void bw_DoWork(object sender, DoWorkEventArgs e)
{
    var stopWatch = Stopwatch.StartNew();
   
     // slow running code
    ...

    stopWatch.Stop();
    Debug.WriteLine("Time taken: "+stopWatch.ElapsedMilliseconds+" ms");   
}


My stopWatch prints out: "Time taken: 119823 ms", but the profiler displays the following values for "Time With Children" (bw_DoWork)

CPU time + Miliseconds : 26.524,787
Wallclock time + miliseconds: 48.699,648

Do you know why I get such a big difference? I could understand if profiled time was greater than the stopwatch due to overhead when creating the thread ect, but how come it is less?
Back to top
View user's profile Send private message
Chris.Allen



Joined: 12 Mar 2009
Posts: 594

PostPosted: Mon Jan 20, 2014 7:07 pm    Post subject: Reply with quote

Was this in sampling mode? Sometimes, when sampling mode doesn't have enough data points it can result in an underestimate.
Back to top
View user's profile Send private message
BrcSen



Joined: 17 Jan 2014
Posts: 2

PostPosted: Tue Jan 21, 2014 8:48 am    Post subject: Reply with quote

I just tried to select Async Mode under View before pressing executing the code I was trying to profile. This gives the result:

Stopwatch: 458056ms
Wall Time: 442265ms
CPU Time: 372429ms

The wall-clock time is much more accurate now, thanks Smile
When should I use async vs sampling?
Back to top
View user's profile Send private message
Chris.Allen



Joined: 12 Mar 2009
Posts: 594

PostPosted: Tue Jan 21, 2014 1:34 pm    Post subject: Reply with quote

Sampling is the mode of choice for longer running projects or projects with a very high degree of CPU usage. The Async feature is really designed to work with the new async keyword. It's great news that you're getting better data now Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group