Exemple #1
0
        private async void GetDataAsync()
        {
            var task = Task.Run(() =>
            {
#if !UNITY_EDITOR && UNITY_ANDROID
                AndroidJNI.AttachCurrentThread();
                float temp = GPerfPlatform.GetCPUUsageRate();
                AndroidJNI.DetachCurrentThread();
#else
                float temp = GPerfPlatform.GetCPUUsageRate();
#endif
                return(temp);
            });

            record.UsageRate = await task;

            var coreFreqTask = Task.Run(() =>
            {
                long[] temp;
#if !UNITY_EDITOR && UNITY_ANDROID
                AndroidJNI.AttachCurrentThread();
                temp = GPerfPlatform.GetCPUCoreFrequence();
                AndroidJNI.DetachCurrentThread();
#else
                temp = GPerfPlatform.GetCPUCoreFrequence();
#endif
                return(temp);
            });

            long[] coreFreq = await coreFreqTask;
            if (coreFreq != null && coreFreq.Length > 0)
            {
                record.CoreFrequency = new int[coreFreq.Length];
                for (int i = 0; i < coreFreq.Length; ++i)
                {
                    record.CoreFrequency[i] = (int)(coreFreq[i] / 1000);
                }
            }
        }