tencent cloud

Tencent Cloud Super App as a Service

DokumentasiTencent Cloud Super App as a Service

Others

Unduh
Mode fokus
Ukuran font
Terakhir diperbarui: 2026-08-14 15:30:54

Query mini game performance snapshots

Superapp developers can use the TmfMiniSDK.queryPerformance API to query real-time performance snapshots of running mini games. It returns metrics such as memory, CPU, rendering frame rate, loading time, and download traffic.

API definition

/**
* Queries the real-time performance snapshot of a running mini game. Supported only for the mini game engine.
*
* @param appid Mini program appid
* @param callback Performance snapshot callback
*/
public static void queryPerformance(String appId, MiniCallback<PerformanceSnapshot> callback)

PerformanceSnapshot field descriptions

Basic information

Field
Description
appId
Mini game appid.
pid
PID of the process where the mini game resides.
pkgVersion
Mini game version.
sdkVersion
SDK version.
baseLibVersion
Base library version.

Loading time

Field
Description
requesttimeMs
Network time spent fetching mini game configuration information.
loadtimeMs
Time from tapping to logic layer readiness (including base library loading and code injection).
readytimeMs
Time from tapping to first screen rendering readiness (appearance of the first frame).

Memory

Field
Description
memoryCurrentKb
Current memory (KB).
memoryAvgKb
Average memory (KB).
memoryPeakKb
Peak memory (KB).
memoryGrowthKb
Memory increment (KB).

CPU

Field
Description
cpuAvg
Average CPU usage (%).
cpuPeak
Peak CPU usage (%).
cpuCurrent
Current CPU usage (%).

Rendering

Field
Description
fpsAvg
Average frame rate. The current frame rate is sampled once per second, and the arithmetic mean of all samples within the session is calculated.
fpsVariance
Frame rate variance. This is the population variance (Σ(fps - mean)² / n, not standard deviation, in fps²) calculated from up to the last 200 per-second FPS samples. A larger variance indicates more severe frame rate jitter and a less stable image; the value itself does not equal frame rate loss.
jankCount
Stuttering count. A jank is recorded when a frame's rendering time is both greater than twice the average of the previous 3 frames and greater than 83.3 ms.
bigJankCount
Severe stuttering count. A bigJank is recorded when a frame's rendering time is both greater than twice the average of the previous 3 frames and greater than 125 ms.

Download and running duration

Field
Description
downloadRecords
All download records during the current runtime, deduplicated by module (keeping the last one). Defaults to an empty list.
module: Subpackage name.
flowBytes: Download traffic.
costMs: Download time.
runningDurationMs
Foreground running duration (ms).

Example

TmfMiniSDK.queryPerformance(appId, (code, msg, snapshot) -> {
if (code == MiniCode.CODE_OK && snapshot != null) {
Log.i(TAG, "fpsAvg=" + snapshot.fpsAvg
+ ", memoryCurrentKb=" + snapshot.memoryCurrentKb
+ ", cpuAvg=" + snapshot.cpuAvg);
} else {
Log.w(TAG, "queryPerformance failed, code=" + code + ", msg=" + msg);
}
});

Notes

1. Valid only for mini games: Only the mini game engine collects these metrics. Calling this API for a standard mini program returns C_CLIENT_MINI_APP_NOT_SUPPORT.
2. Real-time snapshot, not precise statistics: The API returns an instantaneous snapshot at the time of the query, not precise statistics for the entire runtime. Metrics like average, variance, and peak accumulate with sampling points. The shorter the running time and the fewer the samples, the weaker the representativeness.
3. Requires running time to generate data: Memory/CPU sampling heartbeats occur every 10 seconds, whileFPS/jank are sampled every second. When the mini game has just started or has been running in the foreground for only a few seconds, metrics like fpsVariance, peaks, and variances may be 0 or lack reference value.
4. fpsVariance is variance, not standard deviation: The unit is fps², which has a different dimension than the frame rate. It cannot be directly added to or subtracted from fpsAvg ; it is only used for horizontal comparison of frame rate stability. The window limit is 200 samples (about 200 seconds), and older samples are overwritten.
5. jankCount / bigJankCount are cumulative values: They accumulate over the lifecycle of the current process and are not reset when switching between the foreground and background. To observe the stuttering increment during a specific period, you must calculate the difference between two query results yourself.
6. Stuttering criteria are defined by the engine: The thresholds for jank (frame time > 83.3 ms and a sudden increase relative to the previous 3 frames) and bigJank (> 125 ms) are implemented by the MagicBrush engine and may be adjusted with engine versions. We recommend focusing on trend comparisons rather than hardcoding dependencies on the thresholds themselves.
7. Callback thread is not guaranteed to be the main thread: The main process query uses IPC, so the callback may occur on a non-UI thread. Ensure you switch back to the main thread to update the UI.
8. Single query overhead is controllable but non-zero: A query triggers one PSS read and one CPU differential sampling. Avoid high-frequency polling (such as calling it every frame). We recommend querying at a frequency of once per second or lower.



Bantuan dan Dukungan

Apakah halaman ini membantu?

masukan