我正在开发一款休闲游戏。 在我的应用程序还活着之前我很无聊,我可以玩,所以我正在努力减少所有浪费的时间:我使用了OnCreate中通过Thread启动的启动画面;我在一些init中使用了AsyncTask。 但是,阅读logcat,我看到在OnCreate启动的第一条指令之前(也就是对flashscreen线程的调用),我有近6秒的浪费,我不知道为什么......
04-25 20:06:42.043: DEBUG/AndroidRuntime(691): CheckJNI is OFF
04-25 20:06:42.053: INFO/ActivityManager(164): Start proc com.svox.pico for broadcast com.svox.pico/.VoiceDataInstallerReceiver: pid=701 uid=10025 gids={}
04-25 20:06:42.303: INFO/ActivityManager(164): Process com.android.voicedialer (pid 674) has died.
04-25 20:06:42.563: INFO/ActivityThread(701): Publishing provider com.svox.pico.providers.SettingsProvider: com.svox.pico.providers.SettingsProvider
04-25 20:06:42.673: INFO/ActivityManager(164): Start proc com.android.voicedialer for broadcast com.android.voicedialer/.VoiceDialerReceiver: pid=707 uid=10035 gids={3002}
04-25 20:06:43.073: DEBUG/AndroidRuntime(691): --- registering native functions ---
04-25 20:06:43.173: DEBUG/VoiceDialerReceiver(707): onReceive Intent { act=android.intent.action.PACKAGE_ADDED dat=package:com.zapmobilegames.herculaneum flg=0x10000000 cmp=com.android.voicedialer/.VoiceDialerReceiver (has extras) }
04-25 20:06:43.213: VERBOSE/RecognizerEngine(707): deleteCachedGrammarFiles /data/data/com.android.voicedialer/files/openentries.txt
04-25 20:06:43.213: DEBUG/dalvikvm(681): GC_FOR_MALLOC freed 1689 objects / 111200 bytes in 961ms
04-25 20:06:43.303: DEBUG/vending(681): [8] LocalAssetCache.buildCache(): No package info for INSTALLED asset -1596932520012319916 (it.vanini.ottavio.android.utility.bt)
04-25 20:06:43.363: DEBUG/vending(681): [9] LocalAssetDatabase.syncWithPackageManager(): 2 assets for package "com.zapmobilegames.herculaneum": [Ljava.lang.String;@43cb5370
04-25 20:06:43.533: DEBUG/vending(681): [9] LocalAssetDatabase.notifyListener(): -5299042386818461764 / UNINSTALLED
04-25 20:06:43.753: DEBUG/vending(681): [9] LocalAssetDatabase.notifyListener(): -3430589060789413441 / UNINSTALLED
04-25 20:06:43.763: INFO/ActivityManager(164): Process com.pwnwithyourphone.voicecallerid (pid 695) has died.
04-25 20:06:43.823: INFO/ActivityManager(164): Start proc com.google.android.apps.maps:FriendService for broadcast com.google.android.apps.maps/com.google.googlenav.friend.android.ServiceReceiver: pid=718 uid=10042 gids={3003, 1015}
04-25 20:06:44.733: INFO/ActivityManager(164): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.zapmobilegames.herculaneum/.Herculaneum }
04-25 20:06:44.873: DEBUG/AndroidRuntime(691): Shutting down VM
04-25 20:06:44.873: DEBUG/dalvikvm(691): Debugger has detached; object registry had 1 entries
04-25 20:06:44.883: INFO/AndroidRuntime(691): NOTE: attach of thread 'Binder Thread #3' failed
04-25 20:06:44.933: WARN/dalvikvm(691): LinearAlloc 0x0 not freed: 0x410db3a0 len=212
04-25 20:06:44.973: WARN/dalvikvm(691): LinearAlloc 0x0 not freed: 0x410db478 len=572
04-25 20:06:45.023: INFO/ActivityManager(164): Start proc com.zapmobilegames.herculaneum for activity com.zapmobilegames.herculaneum/.Herculaneum: pid=727 uid=10066 gids={3003, 1015}
04-25 20:06:45.153: INFO/ActivityManager(164): Start proc com.google.android.googlequicksearchbox for broadcast com.google.android.googlequicksearchbox/.CorporaUpdateReceiver: pid=732 uid=10038 gids={3003}
04-25 20:06:45.503: INFO/WindowManager(164): Setting rotation to 1, animFlags=1
04-25 20:06:45.583: INFO/ActivityManager(164): Config changed: { scale=1.0 imsi=222/99 loc=it_IT touch=3 keys=1/1/2 nav=3/1 orien=2 layout=18 uiMode=17 seq=4}
04-25 20:06:45.763: INFO/ActivityThread(732): Publishing provider com.google.android.googlequicksearchbox.shortcuts: com.google.android.googlequicksearchbox.ShortcutsProvider
04-25 20:06:45.803: INFO/ActivityManager(164): Process com.android.voicedialer (pid 707) has died.
04-25 20:06:45.863: INFO/ActivityThread(732): Publishing provider com.google.android.googlequicksearchbox.google: com.google.android.googlequicksearchbox.google.GoogleSuggestionProvider
04-25 20:06:46.043: DEBUG/vending(681): [10] LocalAssetDatabase.syncWithPackageManager(): 2 assets for package "com.zapmobilegames.herculaneum": [Ljava.lang.String;@43d0e508
04-25 20:06:46.323: INFO/ActivityThread(727): Publishing provider com.example.AdContentProvider: com.greystripe.android.sdk.AdContentProvider
04-25 20:06:47.213: DEBUG/vending(681): [10] LocalAssetDatabase.notifyListener(): -5299042386818461764 / INSTALLED
04-25 20:06:47.703: DEBUG/vending(681): [10] LocalAssetDatabase.notifyListener(): -3430589060789413441 / INSTALLED
04-25 20:06:47.773: INFO/ActivityManager(164): Process com.google.android.apps.maps:FriendService (pid 718) has died.
还有这一个:
04-25 20:06:47.893: INFO/QC_CORE(92): OMXCORE API - OMX_Init
04-25 20:06:47.893: INFO/QC_CORE(92): OMXCORE API - OMX_ComponentNameEnum 4060ba2c 128 0
04-25 20:06:47.893: INFO/QC_CORE(92): OMXCORE API - OMX_ComponentNameEnum 4060ba2c 128 1
04-25 20:06:47.893: INFO/QC_CORE(92): OMXCORE API - OMX_ComponentNameEnum 4060ba2c 128 2
04-25 20:06:47.893: INFO/QC_CORE(92): OMXCORE API - OMX_ComponentNameEnum 4060ba2c 128 3
04-25 20:06:47.893: INFO/QC_CORE(92): OMXCORE API - OMX_ComponentNameEnum 4060ba2c 128 4
04-25 20:06:47.893: INFO/QC_CORE(92): OMXCORE API - OMX_ComponentNameEnum 4060ba2c 128 5
04-25 20:06:48.093: INFO/QC_CORE(92): OMXCORE API - OMX_Init
04-25 20:06:48.093: INFO/QC_CORE(92): OMXCORE API - OMX_ComponentNameEnum 179e0 128 0
04-25 20:06:48.093: INFO/QC_CORE(92): GetRolesOfComponent OMX.qcom.video.decoder.avc
04-25 20:06:48.093: INFO/QC_CORE(92): GetRolesOfComponent OMX.qcom.video.decoder.avc
04-25 20:06:48.093: INFO/QC_CORE(92): OMXCORE API - OMX_ComponentNameEnum 179e0 128 1
04-25 20:06:48.093: INFO/QC_CORE(92): GetRolesOfComponent OMX.qcom.video.decoder.mpeg4
04-25 20:06:48.093: INFO/QC_CORE(92): GetRolesOfComponent OMX.qcom.video.decoder.mpeg4
04-25 20:06:48.093: INFO/QC_CORE(92): OMXCORE API - OMX_ComponentNameEnum 179e0 128 2
04-25 20:06:48.093: INFO/QC_CORE(92): GetRolesOfComponent OMX.qcom.video.decoder.h263
04-25 20:06:48.093: INFO/QC_CORE(92): GetRolesOfComponent OMX.qcom.video.decoder.h263
04-25 20:06:48.093: INFO/QC_CORE(92): OMXCORE API - OMX_ComponentNameEnum 179e0 128 3
04-25 20:06:48.093: INFO/QC_CORE(92): GetRolesOfComponent OMX.qcom.video.encoder.mpeg4
04-25 20:06:48.093: INFO/QC_CORE(92): GetRolesOfComponent OMX.qcom.video.encoder.mpeg4
04-25 20:06:48.093: INFO/QC_CORE(92): OMXCORE API - OMX_ComponentNameEnum 179e0 128 4
04-25 20:06:48.093: INFO/QC_CORE(92): GetRolesOfComponent OMX.qcom.video.encoder.h263
04-25 20:06:48.093: INFO/QC_CORE(92): GetRolesOfComponent OMX.qcom.video.encoder.h263
04-25 20:06:48.093: INFO/QC_CORE(92): OMXCORE API - OMX_ComponentNameEnum 179e0 128 5
04-25 20:06:48.103: ERROR/(92): A component of name 'OMX.qcom.video.decoder.avc' already exists, ignoring this one.
04-25 20:06:48.103: ERROR/(92): A component of name 'OMX.qcom.video.decoder.mpeg4' already exists, ignoring this one.
04-25 20:06:48.103: ERROR/(92): A component of name 'OMX.qcom.video.decoder.h263' already exists, ignoring this one.
04-25 20:06:48.103: ERROR/(92): A component of name 'OMX.qcom.video.encoder.mpeg4' already exists, ignoring this one.
04-25 20:06:48.103: ERROR/(92): A component of name 'OMX.qcom.video.encoder.h263' already exists, ignoring this one.
04-25 20:06:48.763: INFO/ActivityManager(164): Process com.google.android.voicesearch (pid 656) has died.
04-25 20:06:48.833: VERBOSE/Herculaneum(727): Before splash screen
有任何线索吗?如何加快应用程序的启动?
感谢回复!!!
答案 0 :(得分:3)
步骤1:不要在设备上进行性能测试会运行各种垃圾。虽然这个废话正在启动和停止,但它会从您的应用程序中窃取CPU周期,而您无法控制或预测应用程序级别。在您可以管理的设备上进行性能测试 - 没有应用程序小部件,没有运行后台服务,没有安装其他应用程序等等。
步骤2:在调试器中运行时不要进行性能测试。
有人说......
在04-25 20:06:44.733
,Android开始启动活动。在04-25 20:06:45.023
,您的应用程序的流程已启动。那个四分之一秒是由于你的设备正在发生的其他事情。
在04-25 20:06:45.023
和04-25 20:06:47.703
之间 - 差不多三秒钟 - 我看到一堆看似与您的广告提供商相关的内容。暂时禁用它,看看性能是否有所改善。如果是,请联系您的广告技术提供商(显然是Greystripe)。
BTW,04-25 20:06:44.733
约为04-25 20:06:48.833
之前的4秒,而不是6。