getPerformance
Start from API_LEVEL
4.0. Please refer to API_LEVEL.
Get Mini Program performance statistics, including memory usage and loading performance metrics.
Type
function getPerformance(...args: Array<'memory' | 'perf'>): Result
Parameters
Result
| Property | Type | Description | API_LEVEL |
|---|---|---|---|
| memory | Memory | Memory statistics | 4.0 |
| perf | Perf | Performance statistics | 4.0 |
Memory
| Property | Type | Description | API_LEVEL |
|---|---|---|---|
| system | SystemMemory | system memory information | 4.0 |
| app | Array<AppMemory> | Application memory information list | 4.0 |
| leaking | Array<LeakingMemory> | Unreleased memory information list | 4.0 |
SystemMemory
| Property | Type | Description | API_LEVEL |
|---|---|---|---|
| used | number | Used memory (bytes) | 4.0 |
| total | number | Total memory (bytes) | 4.0 |
AppMemory
| Property | Type | Description | API_LEVEL |
|---|---|---|---|
| appid | number | Mini Program ID | 4.0 |
| used | number | Memory usage (bytes) | 4.0 |
| peak | number | Peak memory usage (bytes) | 4.0 |
| modules | Array<MemoryModule> | Module memory information | 4.0 |
LeakingMemory
| Property | Type | Description | API_LEVEL |
|---|---|---|---|
| appid | number | Mini Program ID | 4.0 |
| used | number | Memory usage (bytes) | 4.0 |
| modules | Array<MemoryModule> | Module memory information | 4.0 |
MemoryModule
| Property | Type | Description | API_LEVEL |
|---|---|---|---|
| file | string | File path | 4.0 |
| used | number | Memory usage (bytes) | 4.0 |
| peak | number | Peak memory usage (bytes) | 4.0 |
Perf
| Property | Type | Description | API_LEVEL |
|---|---|---|---|
| appid | number | Mini Program ID | 4.0 |
| modules | Array<PerfModule> | Module performance information list | 4.0 |
PerfModule
| Property | Type | Description | API_LEVEL |
|---|---|---|---|
| file | string | File name | 4.0 |
| evalTime | number | File reading and running time (excluding lifecycle execution time) | 4.0 |
| createTime | number | onCreate lifecycle execution time | 4.0 |
| initTime | number | onInit lifecycle execution time | 4.0 |
| buildTime | number | build lifecycle execution time | 4.0 |
Example
import { getPerformance } from '@zos/app'
// Get memory info only
const memoryProfile = getPerformance('memory')
// Get both memory and performance info
const fullProfile = getPerformance('memory', 'perf')