# Get updated performance statistics
Start from base library version 2.12.0. Please remaining backward compatible.
If you want to know setData Incurs the overhead of interface updates, you can use the Update Performance Statistics interface. It returns a timestamp of the major update step occurring in each update, which can be used to roughly estimate the performance of a custom component (or page) update. For example:
Component({
attached() { // The call cannot be made earlier than attached
this.setUpdatePerformanceListener({withDataPaths: true}, (res) => {
console.log(res)
})
}
})
setUpdatePerformanceListener Method to accept a options Objects and callback functions listener As parameters.
Among them, options Object contains the following fields:
| field | type | Introductions |
|---|---|---|
| withDataPaths | Boolean | Whether to return the changed Data Field Information |
listeners Return to carry a res Object that represents an object that is defined once by the setData Triggered Update process According to the setData Depending on the timing of the call, the update process can be broadly divided into three categories:
- **Basic update ** , it has a unique
updateProcessId - Subupdate , which is a substep of another basic update and also has the only
updateProcessId♪ but there's another ♪parentUpdateProcessId - Merged Updated , which is merged into another basic update or sub-update process and cannot be counted independently.
Every successful setData Calls will result in an update process that makes listener Call back once. However setData It is difficult to determine what kind of update process is triggered, and the performance of the update is not necessarily related to the specific type of update, but their return value parameters are different.
res Contains the following fields in
| field | type | Introductions |
|---|---|---|
| updateProcessId | Number | This update process. ID |
| parentUpdateProcessId | Number | For a child update, returns the update process to which it belongs ID |
| isMergedUpdate | Boolean | Whether the update is merged, and if so, updateProcessId Represents the update process to be merged into ID |
| dataPaths | Array | This update Data Field information, only the withDataPaths Set to true It will return. |
| pendingStartTimestamp | Number | The timestamp when this update enters the waiting queue |
| updateStartTimestamp | Number | The timestamp at the start of the update operation |
| updateEndTimestamp | Number | The timestamp at the end of the update operation |
Dxplaination:
setUpdatePerformanceListenerWill only activate the statistics of the current component or page,parentUpdateProcessIdThere may be other components or page update process ID If you want to know all the updates in the page, you need to call thesetUpdatePerformanceListener- Statistics itself has a little overhead. If you want to disable statistics, call the
setUpdatePerformanceListenerThe second parameter is passedlistenerfornullJust...