コード例 #1
0
        private static void Calculate()
        {
            for (int i = 1; i < list.Count; i++)
            {
                TimeTask t0 = list[i - 1];
                TimeTask t1 = list[i];


                t0.EndDate  = t1.StartDate;
                t0.Duration = t0.EndDate - t0.StartDate;
            }


            TimeTask t = list.Last();

            t.EndDate  = DateTime.Now;
            t.Duration = t.EndDate - t.StartDate;



            double total = list.Sum(x => x.Duration.TotalMilliseconds);


            foreach (var item in list)
            {
                item.Percentage = Math.Round(item.Duration.TotalMilliseconds * 100.0 / total, 2);
            }


            list.Add(new TimeTask
            {
                Name       = "total",
                StartDate  = list.Min(x => x.StartDate),
                EndDate    = list.Max(x => x.EndDate),
                Duration   = list.Max(x => x.EndDate) - list.Min(x => x.StartDate),
                Percentage = 100.0,
            });
        }
コード例 #2
0
        public static void Add(string Par_Name, MethodBase Par_Method, string Par_Description = "NA")
        {
            if (!DevelopmentMode)
            {
                return;
            }

            TimeTask t = new TimeTask
            {
                ID          = list.Count + 1,
                Name        = Par_Name,
                Description = Par_Description,
                Method      = getMethodName(Par_Method),
                StartDate   = DateTime.Now,
            };

            list.Add(t);

            if (LogAllAddition)
            {
                Console.WriteLine("added new TimeAnalyzer item - " + t.ID + "   " + t.Name + "   " + t.Description + "   " + t.Method + "   " + t.StartDate.ToString("HH:mm:ss.fff"));
            }
        }