Issue
How can I count the time it takes from the moment the user presses the launch button on the home screen until the moment the app is active (for example, until the viewDidAppear method of the first view controller)?
Id does not need to be programmatically but must be reliable.
Analogously in Android, logcat can be used for this effect.
Solution
A simple implementation is to start a StopWatch
in the applications main and then grab the time result in the ViewDidAppear
method:
public class Application
{
public static Stopwatch StartUpTimer;
static void Main(string[] args)
{
StartUpTimer = new Stopwatch();
StartUpTimer.Start();
UIApplication.Main(args, null, "AppDelegate");
}
}
public class MyUIViewController : UIViewController
{
public override void ViewDidAppear (bool animated)
{
Console.WriteLine (Application.StartUpTimer.ElapsedMilliseconds.ToString () + "ms to startup");
base.ViewDidAppear (animated);
}
}
Answered By - matthewrdev
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.