网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

AppLaunchtime101(AndroidPerformancePatternsSeason6Ep.1)

   You know what this timer means? Every quarter second a user spends staring at a blank screen instead of interfacing with your app is a quarter second more. they're willing to close your app and give their attention to something else. misunderstanding all the complex things that happen during your app startup can lead to some serious performance problems.

创新互联建站是一家专业提供当阳企业网站建设,专注与网站建设、成都做网站H5响应式网站、小程序制作等业务。10年已为当阳众多企业、政府机构等服务。创新互联专业网站制作公司优惠进行中。

   Now,see, Android is pretty smart when it comes to understanding human performance perception. As soon as the user launches your application,Android will immediately display a start window,which will stay around untill your application is fully loaded,initialized,and can draw its first frame.

--你知道这个计时器是什么意思吗?【这个不知道怎么翻译,大概意思就是说如果启动时的白屏界面时间过长】。他们会希望把你的app关了,然后去做别的事情。在app启动过程中的那些复杂错误的操作会导致一些严重的性能问题。

  现在我们了解了,android其实是很聪明的,它能够明白人类对性能的感知。一旦用户点击桌面图标,android会立即展示启动窗口,这个窗口将持续,直到你的应用完全加载,初始化,绘制首帧。

  

 App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

This behavior is most often seen when your app is booted for the first time,but it can easily happen other times as well,like when the activity is brought to the foreground,or after the user backs out of your app,or after some portion of your app has been purged by the system to save memory.Basically,any time the user moves from something else to your application, there's a chance you can see this type of behavior.

--这种情况在在app冷启动时候很常见,但是也很容易发生在其他时候,比如活动被置于前台,或者用于退出你的app,或者你的app的某些部分被系统清楚用于节省内存。基本上,任何时候,用户向你的应用转移一些东西(应该是指调用你的app),你也有机会看到这种情况。****套用知乎:cold start:应用第一次启动。   warm start:

   App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

  The important point here is this.Letting the user spend too much time looking at the start window gives then ample opportunity to get bored and move on to other things.And taking too long in general could even cause the Application Not Responding dialog to pop 

up.Neither of these are very good for user retention.

--真正重要的点是这个。让用户花太长时间在启动界面,会让他们感到很枯燥,然后转去做别的事情。并且花太长的时间在这上面,甚至会导致应用弹出无响应弹窗(NAR)。这些对于挽留用户都是没有好处的。

  App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

  So from the technical side,the whole process works something like this.when the user launches your app, the system does a bit of work to load your application information and create a unique process for your app.

--所以,从技术方面,全部的进程工作情况,就如图下图。当用户启动你的app,系统会做一点小工作,加载你的应用信息,给你的app创建一个独立的进程。

  App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

From there,the system will display the strating window and basically hang out until the application is up and running.

--从那以后,系统会显示启动界面并且会持续到应用启动和运行。

 App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

Meanwhile,the application process will create the application object and launch the main thread.

--同时,应用进程会创建应用对象,启动主线程。

  App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

 This is where your startup activity will be initalized,created,inflated,and finally drawn.

--主线程完成activity的初始化,创建,膨胀,绘制。

 App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

it's only at this point,after the application has drawn its first frame,that the system process then goes and swaps out the start window for the application.

--在这点上,当应用绘制了首帧之后,系统进程会把启动窗口替换成app的显示窗口。

   App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

 Now,to be clear,the majority of that entire process happens pretty cleanly.There's not really much chance that performance can go off the rails.However,there are three big areas where things could become problematic that you should keep an eye on.

--现在很清楚了,大多数的进程产生的很干净(大概这个意思吧)。性能出差错的可能性也很小。但是还是有三个大的方面会造成问题,需要你自己关注。

  App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

 The first thing you should really take a look at is all the work that goes into creating your activity class.Most often,there's lots of heavy lifting that occurs during this process,but heaviest has to be the inflation of layouts and loading of resources that goes along with it.This is not a cheap process,and if your layouts are too complex or you've got some blocking logic in there,this can cause some really big problems.

--第一件你需要真正关注的事情就是,所有的工作都会先创建你的activity 类。最经常的,大量繁重任务发生在这个进程期间。但是最繁重的还是inflation布局和加载资源。这不是一个廉价的进程,如果你的布局太复杂,或者是你在这里产生了一些闭锁逻辑,那就会造成×××烦。

 App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

On a similar note,make sure you take a look at application initialization.For really complex apps,the initialization of the app object often becomes a junk drawer for lots of global classes that might be used between activities.So there tends to be lots of work here that could be deferred to later times or perhaps loded in a lazy-load fashion.

--同样的,确定你关注了应用的初始化,对于复杂的app,app对象的初始化经常会成为一个大量全局类的一个垃圾抽屉,可能会被用在活动中(翻译的越来越不行了)。所以这里会有很多工作可能会被推迟,或者是在lazy-load模式下加载。

 App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

Now there's lots of applications out there which provide custom start windows.This is either done to help brand the application or to make a slow load look like a custom-branded application.Now if you're doing this to hide bad load times,obcviously,you should fix that first.But if you're doing it for branding,then you need to be aware that there's a right and a wrong way to set this up,so that it does'nt influence the user perception too negatively.

--现在,很多的应用都会提供启动窗口。或者帮助展示应用品牌,或者降慢应用加载。既然你做这个就是为了隐藏不好的加载时间,那么你就应该修复他。但是如果你设置品牌,那你就应该注意到设置这个的正确和错误的方式。以便不会让用户感觉到太消极。

  App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

But before you run off into the weeds and try to fix these types of common patterns,you need to sit down and figure out if you have a problem in the first place.Thankfully,Android has a few tools to help.

--在解决问题之前,如果你在第一个位置有问题,你需要坐下来,找出它。感谢android有这些工具来帮助我们。

 App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

 Firstly is display time.For releases after KitKat,Logcat will include an output line which displays the amount of time between when the process was launched and the activity finally drawn to the screen.This can be helpful,because it gives you a general idea how long it 

takes to occur for your application.

--首先是显示时间。在KitKat(Android 4.4)版本之后,日志将会包含输出行,它将显示在从程序启动到activity最后绘制在屏幕这段总的时间。这是很有帮助的,对于你的应用启动的时间,他会给出一个大体的建议。

 App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

oh,by the way,not if you want to see this value inisde of Android Studio,you need to turn off filters for the Logcat output. So keep that in mind.

--噢,记住,如果你不想在Android Studio看到这些值,你需要在日志输出上关掉过滤功能。

 App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

 

  Secondly is reportFullyDrawn function.The displayed metric that's repoted in Logcat is useful for most situations where you'd like to track down the time it takes to go from application start to first viseble.Howere,in modern application development,there's often a great deal of lazy loading-that is,rather than blocking the initial drawing of the window,asynchronously loading resources and views in the background and updating the view hierachy accordingly.The result is that while the initial activity may be visible,it may not yet be fully loaded with respect to resources,which could be considered a separate metric to use when evaluating launch time performance.

--其次是reportFullyDrawn方法:我们通常来说会使用异步懒加载的方式来提升程序画面的显示速度,这通常会导致的一个问题是,程序画面已经显示,可是内容却还在加载中。为了衡量这些异步加载资源所耗费的时间,我们可以在异步加载完毕之后调用activity.reportFullyDrawn()方法来告诉系统此时的状态,以便获取整个加载的耗时。

 App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

  To address this concern,you can manually call the activity.reportFullyDrawn function to let the system know that your activity is finished with its lazy loading.

 App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

 Third is method tracing.While display time and reportFullyDrawn give a good understanding of the overall load time of your application,they do not provide details into what may be causing particular parts of that pipeline to go longer than expected.To gain more insight in this area,you can use the start method tracing tool inside of Android Studio.

然后是Method Tracing:前面两个方法提供了启动耗时的总时间,可是却无法提供具体的耗时细节。为了获取具体的耗时分布情况,我们可以使用Method Tracing工具来进行详细的测量。

 App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

 

 And finally is the big one,Systrace.when you add trace functions inside of your onCreate methods,it will augment your logging,such that the Systrace tool can properly discover all the subsections and display them in this graphing process.

--最后的重头戏是Systrace。最后是Systrace:我们可以在onCreate方法里面添加trace方法来声明需要跟踪的起止位置,系统会帮忙统计中间经历过的函数调用耗时,并输出报表。

 App Launch time 101 (Android Performance Patterns Season 6 Ep. 1)

 

 


网站名称:AppLaunchtime101(AndroidPerformancePatternsSeason6Ep.1)
转载注明:http://bjjierui.cn/article/iiiocd.html

其他资讯