iOS应用启动时间测量 [英] iOS app launch time measurement

查看:86
本文介绍了iOS应用启动时间测量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何计算从用户按下主屏幕上的启动按钮到应用激活的时间(例如,直到第一个视图控制器的viewDidAppear方法)所需的时间?

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无需以编程方式进行,但必须可靠.

Id does not need to be programmatically but must be reliable.

类似于Android,logcat可用于实现此效果.

Analogously in Android, logcat can be used for this effect.

推荐答案

一个简单的实现是在应用程序主程序中启动StopWatch,然后在ViewDidAppear方法中获取时间结果:

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);
    }
}

这篇关于iOS应用启动时间测量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆