進階用法
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
以下各節概略說明對程式庫一般作業而言非必要的進階用法相關主題。
其他支援的追蹤器
Tuning Fork 支援多個追蹤器。支援具有以下檢測金鑰的追蹤器:
- 影格開始到下一個影格開始的這段時間 (稱為「
PACED_FRAME_TIME
」)
- CPU 作業時間:從影格開始到 CPU 結束處理影格的這段時間 (稱為「
CPU_TIME
」)
- GPU 作業時間:GPU 將處理的上一個影格的時間 (稱為「
GPU_TIME
」)
- 原始影格時間,也就是 CPU 和 GPU 作業時間的長度上限 (稱為「
RAW_FRAME_TIME
」)。這個選項和 PACED_FRAME_TIME
之間的差異,在於這個選項不包含 Swappy 或 VSync 所包含的任何等待時間。
這些檢測金鑰列於參考說明文件中。
當你啟用 Android 影格速率程式庫時,系統會自動使用其中的部分金鑰;但如果未啟用這個程式庫,請手動使用這些金鑰。
取得擬真度參數
TFErrorCode TuningFork_getFidelityParameters(const CProtobufSerialization*
defaultParams, CProtobufSerialization* params, uint32_t
timeout_ms);
如果你在設定中將 fidelity_params_callback
傳遞至 TuningFork_init
,或程式庫處於資源調度模式,則不需要呼叫此函式。
此函式會與伺服器聯絡,以擷取擬真度參數。封鎖作業會執行至發生下列其中一種情況為止:
- 系統擷取擬真度參數並傳回
TFERROR_OK
的值,並由 returnedParams
儲存參數。在這種情況下,所有後續的滴答資料都會與 returnedParams
建立關聯。
- 傳遞等於
timeout_ms
的毫秒數並傳回 TFERROR_TIMEOUT
的值。在這種情況下,所有後續的滴答資料都會與 defaultFidelityParams
建立關聯。
你必須在這個函式之前呼叫 TuningFork_init()
,而且必須在主執行緒以外的其他執行緒中呼叫 (如需使用可代為呼叫的公用函式,請參閱 TuningFork_startFidelityParamDownloadThread()
)。你可以再次呼叫此函式 (例如在層級載入時),以便再次從伺服器擷取擬真度參數。如此一來,你就能動態更新參數,而不需要在啟動時重新載入參數。如果下載了新的擬真度參數或採用新的預設參數,則系統會提交先前所有的滴答資料。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-08-26 (世界標準時間)。
[null,null,["上次更新時間:2025-08-26 (世界標準時間)。"],[],[],null,["The following sections outline advanced usage topics not needed for normal\noperation of the library.\n\nOther supported tracers\n\nTuning Fork supports multiple tracers. Tracers with the following instrument\nkeys are supported:\n\n- Time between frame starts (called `PACED_FRAME_TIME`)\n- CPU Time: Time between the start of the frame and the end of the CPU work for the frame (called `CPU_TIME`)\n- GPU Time: Time for the previous frame to be handled by the GPU (called `GPU_TIME`)\n- The raw frame time, defined as the maximum of the CPU and GPU time (called `RAW_FRAME_TIME`). The difference between this option and `PACED_FRAME_TIME` is that this option does not include any wait time included by Swappy or VSync.\n\nYou can find these instrument keys in the\n[reference documentation](/games/sdk/reference/performance-tuner/custom-engine).\nSome of these keys are used automatically when you enable the Android Frame\nPacing library, but if you are not enabling this library, you should use them\nexplicitly.\n\nGet fidelity parameters\n\n[`TFErrorCode TuningFork_getFidelityParameters(const CProtobufSerialization*\ndefaultParams, CProtobufSerialization* params, uint32_t\ntimeout_ms);`](/games/sdk/reference/performance-tuner/custom-engine/group/tuningfork#tuningfork_getfidelityparameters)\n\nIf you pass `fidelity_params_callback` to `TuningFork_init` in settings or the\nlibrary is in scaled mode, you do not need to call this function.\n\nThis function contacts a server to retrieve fidelity parameters. It blocks until\none of the following occurs:\n\n- Fidelity parameters are retrieved, with a return value of `TFERROR_OK` and `returnedParams` store the parameters. In this case, all subsequent tick data is associated with `returnedParams`.\n- A number of milliseconds equal to `timeout_ms` passes, with a return value of `TFERROR_TIMEOUT`. In this case, all subsequent tick data is associated with `defaultFidelityParams`.\n\nYou must call `TuningFork_init()` before this function, and you must call it on\na separate thread from the main thread (see\n[`TuningFork_startFidelityParamDownloadThread()`](/games/sdk/reference/performance-tuner/custom-engine/group/tuningfork-extra#tuningfork_startfidelityparamdownloadthread)\nfor a utility function that does this for you). You can call this function\nagain, for example at level-loading time, to retrieve fidelity parameters from\nthe server again. This allows you to dynamically update parameters rather than\nhaving to reload them only at start-up. If new fidelity parameters are\ndownloaded or a new default is used, all previous tick data is submitted."]]