Ejemplo n.º 1
0
        public async Task <string> GetPerformanceChart(PerformanceFilterIOption option)
        {
            if (option.Service.IsEmpty() || option.Service == "ALL")
            {
                option.Service = "";
            }

            if (option.Instance.IsEmpty() || option.Instance == "ALL")
            {
                option.Instance = "";
            }


            List <Performance> performances = new List <Performance>();

            if (option.Start > option.End)
            {
                return(Json(new HttpResultEntity(-1, _lang.TimeRangeFormatError, null)));
            }

            int Times = ((option.End - option.Start).TotalSeconds.ToInt() / option.TimeFormat);

            if (Times >= 60)
            {
                Times = 60;
            }

            var list = await _storage.GetPerformances(option);

            for (int i = 0; i < Times; i++)
            {
                var items = list.Where(x => x.CreateTime >= option.End.AddSeconds(-(i + 1) * option.TimeFormat) && x.CreateTime < option.End.AddSeconds(-i * option.TimeFormat));

                if (!items.Any())
                {
                    continue;
                }

                performances.Insert(0, new Performance {
                    Id                 = option.End.AddSeconds(-i * option.TimeFormat).ToString("mm:ss"),
                    GCGen0             = items.Average(x => x.GCGen0).ToInt(),
                    GCGen1             = items.Average(x => x.GCGen1).ToInt(),
                    GCGen2             = items.Average(x => x.GCGen2).ToInt(),
                    HeapMemory         = items.Average(x => x.HeapMemory).ToString().ToDouble(2),
                    ProcessCPU         = items.Average(x => x.ProcessCPU).ToString().ToDouble(2),
                    ProcessMemory      = items.Average(x => x.ProcessMemory).ToString().ToDouble(2),
                    ThreadCount        = items.Average(x => x.ThreadCount).ToInt(),
                    PendingThreadCount = items.Average(x => x.PendingThreadCount).ToInt()
                });
            }

            return(Json(new HttpResultEntity(1, "ok", performances)));
        }
Ejemplo n.º 2
0
        public async Task <string> GetPerformanceChart(PerformanceFilterIOption option)
        {
            if (option.Start > option.End)
            {
                return(Json(new HttpResultEntity(-1, _lang.TimeRangeFormatError, null)));
            }

            if (option.TimeFormat == 10)
            {
                if (option.Start <= option.End.AddSeconds(-10 * 60))
                {
                    option.Start = option.End.AddSeconds(-10 * 60);
                }
            }

            var list = await _storage.GetPerformances(option);

            return(Json(new HttpResultEntity(1, "ok", list)));
        }