What is the best way to launch an app and calculate its launch time in android(if it can be done with some code,then its better)
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
There will be an automatic log something like
to show the launch time of an app from the user typing on it to the app be ready to interact with user further more. That is from ActivityManager.
Also, using log to measure the time from onCreate() to onResume should be another good way.
To do it fast I would use logcat, something like:
If you want to do something bigger, try Traceview.
You could find the answer here -
This information gets logged on Logcat by default for API version 19 or higher. The key is looking for it in the right place -
Here is the example from the documentation for completeness.
ActivityManager: Displayed com.android.myexample/.StartupTiming: +3s534ms
The extracts are from the documentation.
Hmm - first, to be more precise, I should point out that in Android you start activities, rather than applications!
So, as your entry point to your application is the Activity which handles the LAUNCH intent, one could interpret your question as "how to measure activity start up time".
For this, I suggest to look at an Activities lifecycle here: https://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle.
Looking at the nice graph there, you see that startup time is essentially the time that is spent in
onCreate()
,onStart()
andonResume()
.To measure that, I would suggest to use traceview as this will really show you in all its detail where you spent your time! Start tracing using
Debug.startMethodTracing("startUp");
in the beginning ofonCreate()
and end tracing at the end ofonResume()
withDebug.stopMethodTracing();
.Because
onCreate()
is only called once per instance, you don't even have to worry about multiple calls toonResume()
in case this activity will be put to the background as you will call the stop method twice, which is no harm!Have fun - I like the possibilities of traceview very much!
In scope of answers above I would like to note, what the Traceview unable to provide the real time, due to JIT is turned off while profiling. The Traceview is the useless tool to monitor the time of executing of source's code. (Traceview is a good tools to check stacktrace only, as mentioned above by using Debug class with startMethodTracing() and stopMethodTracing()).
I suggest to use systrace (via Eclipse plugin, for an example) this is best tool to calculate the real time of executing (and many other features).
For more information take a look at: http://developer.android.com/tools/debugging/systrace.html
Also, I want to note that sometimes systrace will not work (depends from FS mapping).
You need to check 'system\core\rootdir\init.rc' with correct of 'debugfs' mounted. Should be as: 'mount debugfs /sys/kernel/debug /sys/kernel/debug'