Beispiel #1
0
        private void ParseMemoryInfo()
        {
            string memoryInfo = GPerfPlatform.GetMemoryInfo();

            if (!string.IsNullOrEmpty(memoryInfo))
            {
                string[] lines = memoryInfo.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
                if (lines != null && lines.Length > 0)
                {
                    foreach (var line in lines)
                    {
                        GPerfUtil.GetKeyValue(line, out var name, out var value);
                        if (name == MEMORY_TOTAL_KEY)
                        {
                            if (!long.TryParse(value, out m_TotalMemInKB))
                            {
                                m_TotalMemInKB = 0L;
                            }
                            m_TotalMemInKB /= GPerfUtil.BYTE_TO_MB_SIZE;
                        }
                        else if (name == MEMORY_AVAILABLE_KEY)
                        {
                            if (!long.TryParse(value, out m_AvailableMemInKB))
                            {
                                m_AvailableMemInKB = 0L;
                            }
                            m_AvailableMemInKB /= GPerfUtil.BYTE_TO_MB_SIZE;
                        }
                        else if (name == MEMORY_THRESHOLD_KEY)
                        {
                            if (!long.TryParse(value, out m_ThresholdInKB))
                            {
                                m_ThresholdInKB = 0L;
                            }
                            m_ThresholdInKB /= GPerfUtil.BYTE_TO_MB_SIZE;
                        }
                        else if (name == MEMORY_IS_LOW_KEY)
                        {
                            if (!bool.TryParse(value, out m_IsLowMemInKB))
                            {
                                m_IsLowMemInKB = false;
                            }
                        }
                        else if (name == MEMORY_PSS_KEY)
                        {
                            if (!long.TryParse(value, out m_PssMemInKB))
                            {
                                m_PssMemInKB = 0L;
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
 public FileRecorder() : base(RecorderType.File)
 {
     m_RootDir = GPerfUtil.GeRootDir();
     if (!string.IsNullOrEmpty(m_RootDir))
     {
         string[] files = Directory.GetFiles(m_RootDir, "gperf_*.log", SearchOption.TopDirectoryOnly);
         if (files != null && files.Length > 0)
         {
             foreach (var file in files)
             {
                 File.Delete(file);
             }
         }
     }
 }
Beispiel #3
0
        public LogSampler()
        {
            MetricType = SamplerMetricType.Log;
            FreqType   = SamplerFreqType.End;

            m_RootDir = GPerfUtil.GeRootDir();

            if (!string.IsNullOrEmpty(m_RootDir))
            {
                string[] files = Directory.GetFiles(m_RootDir, "log_*.log", SearchOption.TopDirectoryOnly);
                if (files != null && files.Length > 0)
                {
                    foreach (var file in files)
                    {
                        File.Delete(file);
                    }
                }
            }
        }