2011-04-25 44 views
0

我正在開發一款休閒遊戲。 我很無聊,等到我的應用程序還沒有活着,我可以玩,所以我試圖減少所有的浪費時間:我用OnCreate中的線程啓動了一個啓動畫面;我爲某些init使用了AsyncTask。 然而,讀取logcat之前,我看到在OnCreate開始的第一條指令(即調用splashscreen線程)之前,我已經浪費了將近6秒鐘,我不知道爲什麼......從啓動到結束OnCreate浪費時間

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 -1596932520(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 

任何線索?我怎樣才能加快我的應用程序的開始?

感謝您的回覆!

回答

3

步驟#1:不要做設備的性能測試將各種廢話運行。儘管垃圾正在啓動和停止,但它正在從您的應用中竊取CPU週期,這是您無法在應用程序級別進行控制或預測的方式。做一個乾淨的設備的性能測試,你可以管理 - 沒有應用程序的小部件,沒有運行的後臺服務,沒有安裝其他應用程序等。

步驟2:不要在調試器中運行時進行性能測試。

話雖這麼說...

04-25 20:06:44.733,機器人開始啓動活動。在04-25 20:06:45.023,您的應用程序的過程已開始。那一秒鐘是由於其他的東西與你的設備。

04-25 20:06:45.02304-25 20:06:47.703之間 - 差不多3秒 - 我看到一堆看起來與您的廣告提供商相關的內容。暫時禁用它並查看性能是否提高。如果確實如此,請聯繫您的廣告技術提供商(顯然是Greystripe)。

BTW,04-25 20:06:44.73304-25 20:06:48.833前約4秒,而不是6

+0

謝謝CW。對於第一步這肯定會涉及到用戶的手機,所以我可以不關心滯後,不是嗎?那麼,在這種情況下,這是我的手機,但無論如何它不涉及我的應用程序,所以我不能改善我的應用程序的開始時間,因爲它與其他垃圾的東西有關。對於第二步,你能否提出其他類型的性能測試?我只知道這個與調試器連接。其餘的,我會檢查Greystripe滯後。最後,你認爲我的啓動時間可以接受嗎?有時候我有一個討厭的ANR盒子(可能與背景中的東西有關)。 – Zappescu 2011-04-26 12:17:05

+0

@ Zappescu:「對於第二步,你能否提出其他類型的性能測試?我只知道這個附帶調試器的測試。」 - 拔下手機。運行測試。將手機插入。查看日誌中的結果。 「最後,你認爲我的啓動時間可以接受嗎?」 - 如果你正在獲得ANR,則不需要。 – CommonsWare 2011-04-26 12:23:25

+0

他的啓動時間可能會在日誌中顯示4秒,但這並不意味着所有組件都已加載並可以使用。我注意到在幾個應用程序中日誌文件會說它的加載,但實際的繪畫和其他任何事情發生幾秒鐘後都不會發生。 – JPM 2011-09-07 14:36:39