Hi, I'm using Xamarin time profiler for profiling a Xamarin Android application. The code snippet for which I'm trying to capture the execution time is provided below. The stopwatch.ElapsedMilliseconds is giving the result as 10000ms. When I check this in Xamarin time profiler, it displays the running time as 4.69s (ie. 4690ms). Why is this difference? What exactly Xamarin time profiler is capturing?
void TestMethod()
{
//Stopwatch stopwatch = new Stopwatch();
//stopwatch.Start();
for (int i = 0; i < 5; i++)
{
Thread.Sleep(2000);
}
//stopwatch.Stop();
//Console.WriteLine("Time for testmethod(): " + stopwatch.ElapsedMilliseconds);
}
Also, I tried to capture the execution time for the following code snippet without using Thread.Sleep. The stopwatch.ElapsedMilliseconds displays around 84000ms and Xamarin time profiler displays the running time as 22.64s (ie. 22640ms).
void TestMethod()
{
//Stopwatch stopwatch = new Stopwatch();
//stopwatch.Start();
for (int i = 0; i < 1000000; i++)
{
Console.WriteLine("Test statement");
}
//stopwatch.Stop();
//Console.WriteLine("Time for testmethod(): " + stopwatch.ElapsedMilliseconds);
}
Note: I'm using Xamarin profiler beta version 1.6.1.483. Also tried Xamarin profiler stable version 1.6.0.27. Still seeing the difference between the results captured from stopwatch.ElapsedMilliseconds and xamarin profiler.