1e41f4b71Sopenharmony_ci# Speeding Up Application Cold Start 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciApplication startup latency is a key factor that affects user experience. When an application is started, the background does not have a process of the application, and therefore the system creates a new process and allocates it to the application. This startup mode is called cold start. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci## Analyzing the Time Required for Application Cold Start 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciThe cold start process of applications can be divided into four phases: application process creation and initialization, application and ability initialization, ability/ability stage lifecycle, and home page loading and drawing, as shown below. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci## 1. Shortening Time Required for Application Process Creation And Initialization 12e41f4b71Sopenharmony_ci 13e41f4b71Sopenharmony_ciIn the phase of application process creation and initialization, the system creates and initializes an application process, including decoding the icon of the startup page (specified by **startWindowIcon**). 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci### Using startWindowIcon of Appropriate Resolution 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ciWith regard to the icon of the startup page, the recommended maximum resolution is 256 x 256 pixels. Larger resolutions may result in slow startup. 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci```json 20e41f4b71Sopenharmony_ci "abilities": [ 21e41f4b71Sopenharmony_ci { 22e41f4b71Sopenharmony_ci "name": "EntryAbility", 23e41f4b71Sopenharmony_ci "srcEntry": "./ets/entryability/EntryAbility.ets", 24e41f4b71Sopenharmony_ci "description": "$string:EntryAbility_desc", 25e41f4b71Sopenharmony_ci "icon": "$media:icon", 26e41f4b71Sopenharmony_ci "label": "$string:EntryAbility_label", 27e41f4b71Sopenharmony_ci "startWindowIcon": "$media:startIcon", // Modify the icon of the startup page. It is recommended that the icon be less than or equal to 256 x 256 pixels. 28e41f4b71Sopenharmony_ci "startWindowBackground": "$color:start_window_background", 29e41f4b71Sopenharmony_ci "exported": true, 30e41f4b71Sopenharmony_ci "skills": [ 31e41f4b71Sopenharmony_ci { 32e41f4b71Sopenharmony_ci "entities": [ 33e41f4b71Sopenharmony_ci "entity.system.home" 34e41f4b71Sopenharmony_ci ], 35e41f4b71Sopenharmony_ci "actions": [ 36e41f4b71Sopenharmony_ci "action.system.home" 37e41f4b71Sopenharmony_ci ] 38e41f4b71Sopenharmony_ci } 39e41f4b71Sopenharmony_ci ] 40e41f4b71Sopenharmony_ci } 41e41f4b71Sopenharmony_ci ] 42e41f4b71Sopenharmony_ci``` 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ciThe following uses the [SmartPerf](https://gitee.com/openharmony/developtools_smartperf_host) tool to compare the startup performance of the startup page icon before optimization (4096 x 4096 pixels) with that after optimization (144 x 144 pixels). The analysis starts when the ability is started (that is, the start point of **H:void OHOS::AppExecFwk::MainThread::HandleLaunchAbility**), and ends when **vsync** is received for the first time (that is, the start point of **H:ReceiveVsync dataCount:24Bytes now:timestamp expectedEnd:timestamp vsyncId:int**). 45e41f4b71Sopenharmony_ci 46e41f4b71Sopenharmony_ciThe comparison data is as follows. 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci| | Start (s) | End (s) | Duration (s)| 49e41f4b71Sopenharmony_ci| ---------------------- | -------------- | -------------- | ------------ | 50e41f4b71Sopenharmony_ci| Before optimization | 5419.484537973 | 5420.327775266 | 0.843237293 | 51e41f4b71Sopenharmony_ci| After optimization | 4186.436835246 | 4186.908777335 | 0.471942089 | 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ciAs the comparison shows, setting **startWindowIcon** to an icon with an appropriate resolution is effective for shortening the duration of application process creation and initialization. 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ci## 2. Shortening Time Required for Application and Ability Initialization 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ciIn the phase of application and ability initialization, resources are loaded, virtual machines are created, application and ability related objects are created and initialized, and dependent modules are loaded. 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci### Minimizing the Number of Imported Modules 60e41f4b71Sopenharmony_ci 61e41f4b71Sopenharmony_ciBefore executing code, an application must find and load all imported modules. Naturally, each additional third-party framework or module to be loaded by the application increases its startup time. The time required depends on the number and size of the third-party frameworks or modules to load. As such, to speed up startup, use system-provided modules whenever possible and load the modules as required. 62e41f4b71Sopenharmony_ci 63e41f4b71Sopenharmony_ciThe sample code is as follows: 64e41f4b71Sopenharmony_ci 65e41f4b71Sopenharmony_ci```ts 66e41f4b71Sopenharmony_ci// Reduce the number of imported modules. 67e41f4b71Sopenharmony_ci// import ability from '@ohos.ability.ability'; 68e41f4b71Sopenharmony_ci// import dataUriUtils from '@ohos.ability.dataUriUtils'; 69e41f4b71Sopenharmony_ci// import errorCode from '@ohos.ability.errorCode'; 70e41f4b71Sopenharmony_ci// import featureAbility from '@ohos.ability.featureAbility'; 71e41f4b71Sopenharmony_ci// import particleAbility from '@ohos.ability.particleAbility'; 72e41f4b71Sopenharmony_ci// import wantConstant from '@ohos.ability.wantConstant'; 73e41f4b71Sopenharmony_ci// import common from '@ohos.app.ability.common'; 74e41f4b71Sopenharmony_ci// import Configuration from '@ohos.app.ability.Configuration'; 75e41f4b71Sopenharmony_ci// import contextConstant from '@ohos.app.ability.contextConstant'; 76e41f4b71Sopenharmony_ci// import ConfigurationConstant from '@ohos.app.ability.ConfigurationConstant'; 77e41f4b71Sopenharmony_ci// import FormExtensionAbility from '@ohos.app.form.FormExtensionAbility'; 78e41f4b71Sopenharmony_ci// import GesturePath from '@ohos.accessibility.GesturePath'; 79e41f4b71Sopenharmony_ci// import GesturePoint from '@ohos.accessibility.GesturePoint'; 80e41f4b71Sopenharmony_ci// import distributedAccount from '@ohos.account.distributedAccount'; 81e41f4b71Sopenharmony_ci// import osAccount from '@ohos.account.osAccount'; 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_ciimport AbilityConstant from '@ohos.app.ability.AbilityConstant'; 84e41f4b71Sopenharmony_ciimport UIAbility from '@ohos.app.ability.UIAbility'; 85e41f4b71Sopenharmony_ciimport Want from '@ohos.app.ability.Want'; 86e41f4b71Sopenharmony_ciimport window from '@ohos.window'; 87e41f4b71Sopenharmony_ciimport logger from '../common/Logger'; 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility { 90e41f4b71Sopenharmony_ci // ... 91e41f4b71Sopenharmony_ci} 92e41f4b71Sopenharmony_ci``` 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ciThe following uses the [SmartPerf](https://gitee.com/openharmony/developtools_smartperf_host) tool to compare the startup performance before optimization (20 imported modules) with that after optimization (5 imported modules). The analysis starts when the ability is started (that is, the start point of **H:void OHOS::AppExecFwk::MainThread::HandleLaunchAbility**), and ends when **vsync** is received for the first time (that is, the start point of **H:ReceiveVsync dataCount:24Bytes now:timestamp expectedEnd:timestamp vsyncId:int**). 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ciThe comparison data is as follows. 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ci| | Start (s) | End (s) | Duration (s)| 99e41f4b71Sopenharmony_ci| ------------------ | -------------- | -------------- | ------------ | 100e41f4b71Sopenharmony_ci| Before optimization| 3042.259391282 | 3046.385614613 | 4.126223331 | 101e41f4b71Sopenharmony_ci| Before optimization| 4186.436835246 | 4186.908777335 | 0.471942089 | 102e41f4b71Sopenharmony_ci 103e41f4b71Sopenharmony_ciAs the comparison shows, reducing the number of imported modules is effective for shortening the duration of application and ability initialization. 104e41f4b71Sopenharmony_ci 105e41f4b71Sopenharmony_ci## 3. Shortening Time Required for AbilityStage Lifecycle 106e41f4b71Sopenharmony_ci 107e41f4b71Sopenharmony_ciIn this phase of AbilityStage lifecycle, the AbilityStage lifecycle callbacks are executed. 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_ci### Avoiding Time-Consuming Operations in AbilityStage Lifecycle Callbacks 110e41f4b71Sopenharmony_ci 111e41f4b71Sopenharmony_ciIn the application startup process, the system executes the AbilityStage lifecycle callbacks. Whenever possible, avoid performing time-consuming operations in these callbacks. You are advised to perform time-consuming operations through asynchronous tasks or execute them in other threads. 112e41f4b71Sopenharmony_ci 113e41f4b71Sopenharmony_ciIn these lifecycle callbacks, perform only necessary operations. For details, see [AbilityStage Component Container](../application-models/abilitystage.md). 114e41f4b71Sopenharmony_ci 115e41f4b71Sopenharmony_ciThe sample code is as follows: 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ci```ts 118e41f4b71Sopenharmony_ciconst LARGE_NUMBER = 10000000; 119e41f4b71Sopenharmony_ciconst DELAYED_TIME = 1000; 120e41f4b71Sopenharmony_ci 121e41f4b71Sopenharmony_ciexport default class MyAbilityStage extends AbilityStage { 122e41f4b71Sopenharmony_ci onCreate(): void { 123e41f4b71Sopenharmony_ci // Time-consuming operation 124e41f4b71Sopenharmony_ci // this.computeTask(); 125e41f4b71Sopenharmony_ci this.computeTaskAsync(); // Asynchronous task 126e41f4b71Sopenharmony_ci } 127e41f4b71Sopenharmony_ci 128e41f4b71Sopenharmony_ci onAcceptWant(want: Want): string { 129e41f4b71Sopenharmony_ci // Triggered only for the ability with the specified launch type. 130e41f4b71Sopenharmony_ci return 'MyAbilityStage'; 131e41f4b71Sopenharmony_ci } 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ci computeTask(): void { 134e41f4b71Sopenharmony_ci let count = 0; 135e41f4b71Sopenharmony_ci while (count < LARGE_NUMBER) { 136e41f4b71Sopenharmony_ci count++; 137e41f4b71Sopenharmony_ci } 138e41f4b71Sopenharmony_ci } 139e41f4b71Sopenharmony_ci 140e41f4b71Sopenharmony_ci private computeTaskAsync(): void { 141e41f4b71Sopenharmony_ci setTimeout(() => {// setTimeout is used to implement asynchronous processing. 142e41f4b71Sopenharmony_ci this.computeTask(); 143e41f4b71Sopenharmony_ci }, DELAYED_TIME); 144e41f4b71Sopenharmony_ci } 145e41f4b71Sopenharmony_ci} 146e41f4b71Sopenharmony_ci``` 147e41f4b71Sopenharmony_ci 148e41f4b71Sopenharmony_ciThe following uses the [SmartPerf](https://gitee.com/openharmony/developtools_smartperf_host) tool to compare the startup performance before optimization (with synchronous operations) with that after optimization (with asynchronous operations). The analysis starts when the ability is started (that is, the start point of **H:void OHOS::AppExecFwk::MainThread::HandleLaunchAbility**), and ends when **vsync** is received for the first time (that is, the start point of **H:ReceiveVsync dataCount:24Bytes now:timestamp expectedEnd:timestamp vsyncId:int**). 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ciThe comparison data is as follows. 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci| | Start (s) | End (s) | Duration (s)| 153e41f4b71Sopenharmony_ci| ---------------------- | -------------- | -------------- | ------------ | 154e41f4b71Sopenharmony_ci| Before optimization| 2124.915558194 | 2127.041354575 | 2.125796381 | 155e41f4b71Sopenharmony_ci| After optimization| 4186.436835246 | 4186.908777335 | 0.471942089 | 156e41f4b71Sopenharmony_ci 157e41f4b71Sopenharmony_ciAs the comparison shows, avoiding time-consuming operations in AbilityStage lifecycle callbacks is effective for shortening the time required for the AbilityStage lifecycle. 158e41f4b71Sopenharmony_ci 159e41f4b71Sopenharmony_ci## 4. Shortening Time Required for Ability Lifecycle 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_ciIn this phase of ability lifecycle, the ability lifecycle callbacks are executed. 162e41f4b71Sopenharmony_ci 163e41f4b71Sopenharmony_ci### Avoiding Time-Consuming Operations in Ability Lifecycle Callbacks 164e41f4b71Sopenharmony_ci 165e41f4b71Sopenharmony_ciIn the application startup process, the system executes the ability lifecycle callbacks. Whenever possible, avoid performing time-consuming operations in these callbacks. You are advised to perform time-consuming operations through asynchronous tasks or execute them in other threads. 166e41f4b71Sopenharmony_ci 167e41f4b71Sopenharmony_ciIn these lifecycle callbacks, perform only necessary operations. The following uses the UIAbility as an example. For details about the UIAbility lifecycle, see [UIAbility Lifecycle](../application-models/uiability-lifecycle.md). 168e41f4b71Sopenharmony_ci 169e41f4b71Sopenharmony_ci```ts 170e41f4b71Sopenharmony_ciconst LARGE_NUMBER = 10000000; 171e41f4b71Sopenharmony_ciconst DELAYED_TIME = 1000; 172e41f4b71Sopenharmony_ci 173e41f4b71Sopenharmony_ciexport default class EntryAbility extends UIAbility { 174e41f4b71Sopenharmony_ci onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { 175e41f4b71Sopenharmony_ci logger.info('Ability onCreate'); 176e41f4b71Sopenharmony_ci // Time-consuming operation 177e41f4b71Sopenharmony_ci // this.computeTask(); 178e41f4b71Sopenharmony_ci this.computeTaskAsync(); // Asynchronous task 179e41f4b71Sopenharmony_ci } 180e41f4b71Sopenharmony_ci 181e41f4b71Sopenharmony_ci onDestroy(): void { 182e41f4b71Sopenharmony_ci logger.info('Ability onDestroy'); 183e41f4b71Sopenharmony_ci } 184e41f4b71Sopenharmony_ci 185e41f4b71Sopenharmony_ci onWindowStageCreate(windowStage: window.WindowStage): void { 186e41f4b71Sopenharmony_ci logger.info('Ability onWindowStageCreate'); 187e41f4b71Sopenharmony_ci 188e41f4b71Sopenharmony_ci windowStage.loadContent('pages/Index', (err, data) => { 189e41f4b71Sopenharmony_ci if (err.code) { 190e41f4b71Sopenharmony_ci logger.error('Failed to load the content. Cause: ' + JSON.stringify(err) ?? ''); 191e41f4b71Sopenharmony_ci return; 192e41f4b71Sopenharmony_ci } 193e41f4b71Sopenharmony_ci logger.info('Succeeded in loading the content. Data: ' + JSON.stringify(data) ?? ''); 194e41f4b71Sopenharmony_ci }); 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_ci // Time-consuming operation 197e41f4b71Sopenharmony_ci // this.computeTask(); 198e41f4b71Sopenharmony_ci this.computeTaskAsync(); // Asynchronous task 199e41f4b71Sopenharmony_ci } 200e41f4b71Sopenharmony_ci 201e41f4b71Sopenharmony_ci onWindowStageDestroy(): void { 202e41f4b71Sopenharmony_ci logger.info('Ability onWindowStageDestroy'); 203e41f4b71Sopenharmony_ci } 204e41f4b71Sopenharmony_ci 205e41f4b71Sopenharmony_ci onForeground(): void { 206e41f4b71Sopenharmony_ci logger.info('Ability onForeground'); 207e41f4b71Sopenharmony_ci // Time-consuming operation 208e41f4b71Sopenharmony_ci // this.computeTask(); 209e41f4b71Sopenharmony_ci this.computeTaskAsync(); // Asynchronous task 210e41f4b71Sopenharmony_ci } 211e41f4b71Sopenharmony_ci 212e41f4b71Sopenharmony_ci onBackground(): void { 213e41f4b71Sopenharmony_ci logger.info('Ability onBackground'); 214e41f4b71Sopenharmony_ci } 215e41f4b71Sopenharmony_ci 216e41f4b71Sopenharmony_ci computeTask(): void { 217e41f4b71Sopenharmony_ci let count = 0; 218e41f4b71Sopenharmony_ci while (count < LARGE_NUMBER) { 219e41f4b71Sopenharmony_ci count++; 220e41f4b71Sopenharmony_ci } 221e41f4b71Sopenharmony_ci } 222e41f4b71Sopenharmony_ci 223e41f4b71Sopenharmony_ci private computeTaskAsync(): void { 224e41f4b71Sopenharmony_ci setTimeout(() => {// setTimeout is used to implement asynchronous processing. 225e41f4b71Sopenharmony_ci this.computeTask(); 226e41f4b71Sopenharmony_ci }, DELAYED_TIME); 227e41f4b71Sopenharmony_ci } 228e41f4b71Sopenharmony_ci} 229e41f4b71Sopenharmony_ci``` 230e41f4b71Sopenharmony_ci 231e41f4b71Sopenharmony_ciThe following uses the [SmartPerf](https://gitee.com/openharmony/developtools_smartperf_host) tool to compare the startup performance before optimization (with synchronous operations) with that after optimization (with asynchronous operations). The analysis starts when the ability is started (that is, the start point of **H:void OHOS::AppExecFwk::MainThread::HandleLaunchAbility**), and ends when **vsync** is received for the first time (that is, the start point of **H:ReceiveVsync dataCount:24Bytes now:timestamp expectedEnd:timestamp vsyncId:int**). 232e41f4b71Sopenharmony_ci 233e41f4b71Sopenharmony_ciThe comparison data is as follows. 234e41f4b71Sopenharmony_ci 235e41f4b71Sopenharmony_ci| | Start (s) | End (s) | Duration (s)| 236e41f4b71Sopenharmony_ci| ---------------------- | -------------- | -------------- | ------------ | 237e41f4b71Sopenharmony_ci| Before optimization| 1954.987630036 | 1957.565964504 | 2.578334468 | 238e41f4b71Sopenharmony_ci| After optimization| 4186.436835246 | 4186.908777335 | 0.471942089 | 239e41f4b71Sopenharmony_ci 240e41f4b71Sopenharmony_ciAs the comparison shows, avoiding time-consuming operations in ability lifecycle callbacks is effective for shortening the time required for the ability lifecycle. 241e41f4b71Sopenharmony_ci 242e41f4b71Sopenharmony_ci## 5. Shortening Time Required for Home Page Loading and Drawing 243e41f4b71Sopenharmony_ci 244e41f4b71Sopenharmony_ciIn this phase of home page loading and drawing, the home page content is loaded, the layout is measured, and components are refreshed and drawn. 245e41f4b71Sopenharmony_ci 246e41f4b71Sopenharmony_ci### Avoid time-consuming operations in the custom component lifecycle callbacks. 247e41f4b71Sopenharmony_ci 248e41f4b71Sopenharmony_ciWhen the lifecycle of a custom component changes, the corresponding callback is called. 249e41f4b71Sopenharmony_ci 250e41f4b71Sopenharmony_ciThe **aboutToAppear** function is executed after the custom component instance is created and before the page is drawn. The following code asynchronously processes the time-consuming computing task in **aboutToAppear** to avoid executing the operation in this function and blocking the page drawing. 251e41f4b71Sopenharmony_ci 252e41f4b71Sopenharmony_ciThe sample code is as follows: 253e41f4b71Sopenharmony_ci 254e41f4b71Sopenharmony_ci```ts 255e41f4b71Sopenharmony_ciconst LARGE_NUMBER = 10000000; 256e41f4b71Sopenharmony_ciconst DELAYED_TIME = 1000; 257e41f4b71Sopenharmony_ci 258e41f4b71Sopenharmony_ci@Entry 259e41f4b71Sopenharmony_ci@Component 260e41f4b71Sopenharmony_cistruct Index { 261e41f4b71Sopenharmony_ci @State private text: string = ""; 262e41f4b71Sopenharmony_ci private count: number = 0; 263e41f4b71Sopenharmony_ci 264e41f4b71Sopenharmony_ci aboutToAppear() { 265e41f4b71Sopenharmony_ci // Time-consuming operation 266e41f4b71Sopenharmony_ci // this.computeTask(); 267e41f4b71Sopenharmony_ci this.computeTaskAsync(); // Asynchronous task 268e41f4b71Sopenharmony_ci let context = getContext(this) as Context; 269e41f4b71Sopenharmony_ci this.text = context.resourceManager.getStringSync($r('app.string.startup_text')); 270e41f4b71Sopenharmony_ci } 271e41f4b71Sopenharmony_ci 272e41f4b71Sopenharmony_ci build() { 273e41f4b71Sopenharmony_ci Column({ space: 10 }) { 274e41f4b71Sopenharmony_ci Text(this.text).fontSize(50) 275e41f4b71Sopenharmony_ci } 276e41f4b71Sopenharmony_ci .width('100%') 277e41f4b71Sopenharmony_ci .height('100%') 278e41f4b71Sopenharmony_ci .padding(10) 279e41f4b71Sopenharmony_ci } 280e41f4b71Sopenharmony_ci 281e41f4b71Sopenharmony_ci computeTask(): void { 282e41f4b71Sopenharmony_ci this.count = 0; 283e41f4b71Sopenharmony_ci while (this.count < LARGE_NUMBER) { 284e41f4b71Sopenharmony_ci this.count++; 285e41f4b71Sopenharmony_ci } 286e41f4b71Sopenharmony_ci let context = getContext(this) as Context; 287e41f4b71Sopenharmony_ci this.text = context.resourceManager.getStringSync($r('app.string.task_text')); 288e41f4b71Sopenharmony_ci } 289e41f4b71Sopenharmony_ci 290e41f4b71Sopenharmony_ci // Asynchronous processing of the computing task 291e41f4b71Sopenharmony_ci private computeTaskAsync(): void { 292e41f4b71Sopenharmony_ci setTimeout(() => {// setTimeout is used to implement asynchronous processing. 293e41f4b71Sopenharmony_ci this.computeTask(); 294e41f4b71Sopenharmony_ci }, DELAYED_TIME); 295e41f4b71Sopenharmony_ci } 296e41f4b71Sopenharmony_ci} 297e41f4b71Sopenharmony_ci``` 298e41f4b71Sopenharmony_ci 299e41f4b71Sopenharmony_ciThe following uses the [SmartPerf](https://gitee.com/openharmony/developtools_smartperf_host) tool to compare the startup performance before optimization (with synchronous operations) with that after optimization (with asynchronous operations). The analysis starts when the ability is started (that is, the start point of **H:void OHOS::AppExecFwk::MainThread::HandleLaunchAbility**), and ends when **vsync** is received for the first time (that is, the start point of **H:ReceiveVsync dataCount:24Bytes now:timestamp expectedEnd:timestamp vsyncId:int**). 300e41f4b71Sopenharmony_ci 301e41f4b71Sopenharmony_ciThe comparison data is as follows. 302e41f4b71Sopenharmony_ci 303e41f4b71Sopenharmony_ci| | Start (s) | End (s) | Duration (s)| 304e41f4b71Sopenharmony_ci| ---------------------- | -------------- | -------------- | ------------ | 305e41f4b71Sopenharmony_ci| Before optimization| 3426.272974492 | 3431.785898837 | 5.512924345 | 306e41f4b71Sopenharmony_ci| After optimization| 4186.436835246 | 4186.908777335 | 0.471942089 | 307e41f4b71Sopenharmony_ci 308e41f4b71Sopenharmony_ciAs the comparison shows, avoiding time-consuming operations in custom component lifecycle callbacks is effective for shortening the time required for home page loading and drawing. 309