android添加时间,添加加载时间记录函数
記錄游戲執(zhí)行加載的時(shí)間非常重要,原因有兩個(gè):
避免在加載時(shí)污染幀時(shí)間數(shù)據(jù)。
分析加載時(shí)間,看看加載時(shí)間何時(shí)何地超過可接受的范圍。
加載事件可以具有關(guān)聯(lián)的元數(shù)據(jù):
typedef struct TuningFork_LoadingTimeMetadata {
enum LoadingState {
UNKNOWN_STATE = 0,
// The first time the game is run
FIRST_RUN = 1,
// App is not backgrounded
COLD_START = 2,
// App is backgrounded
WARM_START = 3,
// App is backgrounded, least work needed
HOT_START = 4,
// Asset loading between levels
INTER_LEVEL = 5
} state;
enum LoadingSource {
UNKNOWN_SOURCE = 0,
// Uncompressing data.
MEMORY = 1,
// Reading assets from APK bundle.
APK = 2,
// Reading assets from device storage.
DEVICE_STORAGE = 3,
// Reading assets from external storage, e.g. SD card.
EXTERNAL_STORAGE = 4,
// Loading assets from the network.
NETWORK = 5,
// Shader compilation.
SHADER_COMPILATION = 6,
// Time spent between process starting and onCreate.
PRE_ACTIVITY = 7,
// Total time spent between process starting and first render frame.
FIRST_TOUCH_TO_FIRST_FRAME = 8
} source;
int32_t compression_level; // 0 = no compression, 100 = max compression
enum NetworkConnectivity {
UNKNOWN = 0,
WIFI = 1,
CELLULAR_NETWORK = 2
} network_connectivity;
uint64_t network_transfer_speed_bps; // bandwidth in bits per second
uint64_t network_latency_ns; // latency in nanoseconds
} TuningFork_LoadingTimeMetadata;
任何與您的需求無關(guān)的字段都可以為零。
加載事件還可以具有關(guān)聯(lián)的注釋。它的定義方式與幀時(shí)間注釋相同,那就是使用 dev_tuningfork.proto 文件的 Annotation 消息中的一個(gè)或多個(gè)字段。
此函數(shù)開始記錄與給定的元數(shù)據(jù)和注釋關(guān)聯(lián)的加載時(shí)間事件,并填充要在 TuningFork_stopRecordingLoadingTime() 函數(shù)中使用的 handle。
此函數(shù)停止記錄之前由 TuningFork_startRecordingLoadingTime() 開始的事件。該事件會在下次會話刷新時(shí)上傳。
我們強(qiáng)烈建議直接使用前面所述的開始和停止函數(shù)。不過,如果您無法執(zhí)行此操作,則可以調(diào)用此函數(shù)來記錄持續(xù)時(shí)間及其關(guān)聯(lián)的元數(shù)據(jù)和注釋。
加載組函數(shù)
在您的游戲中,您可以為用戶看到的一個(gè)加載期間記錄多個(gè)加載事件。一些示例包括(但不限于)文件加載、解壓縮和著色器編譯。
務(wù)必告知 Tuning Fork,加載事件是此類組的一部分,以便它可以提供更好的數(shù)據(jù)分析。為此,請將加載事件與以下開始和停止函數(shù)括在一起。
注意:一次只能有一個(gè)加載組處于活動狀態(tài)。
此函數(shù)開始與給定的元數(shù)據(jù)和注釋關(guān)聯(lián)的加載組,并填充要在 TuningFork_stopLoadingGroup() 函數(shù)中使用的 handle。Play 后端當(dāng)前不使用元數(shù)據(jù)和注釋,您可以將其設(shè)置為 nullptr。所有后續(xù)加載事件都將由唯一的組 ID 來標(biāo)記。
此函數(shù)停止之前由 TuningFork_startLoadingGroup() 開始的加載組。后續(xù)加載事件將沒有組 ID,直到再次調(diào)用 TuningFork_startLoadingGroup()。
總結(jié)
以上是生活随笔為你收集整理的android添加时间,添加加载时间记录函数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 徽商银行信用卡消费分期/账单分期怎么提前
- 下一篇: android 绕过root检测,公主连