Wrong time displayed
BrcSen
Posts: 3
Hi
Im trying to profile some code in a backgroundworker (wpf application, .net 4.0 Client Profile). The pseudocode is:
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?
Im trying to profile some code in a backgroundworker (wpf application, .net 4.0 Client Profile). The pseudocode is:
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?
Comments
Stopwatch: 458056ms
Wall Time: 442265ms
CPU Time: 372429ms
The wall-clock time is much more accurate now, thanks
When should I use async vs sampling?